def acquisition_labels_stats(dat): reso, n, path, test, tiles = dat with buzz.Env(significant=9): ds = buzz.DataSource() ds.open_raster('labs', path) numerators_acq = np.zeros(LABEL_COUNT, int) denominators_acq = np.zeros(LABEL_COUNT, int) for fp in tiles: counts_tile = np.bincount( ds.labs.get_data(fp=fp).flatten(), None, LABEL_COUNT) numerators_acq += counts_tile denominators_acq += (counts_tile > 0) * fp.rarea numerators_acq = numerators_acq * reso**2 / 1e4 denominators_acq = denominators_acq * reso**2 / 1e4 numerators_acq = [ (('nume', catname), nbr) for catname, nbr in zip(CATEGORIES, numerators_acq) ] denominators_acq = [ (('deno', catname), nbr) for catname, nbr in zip(CATEGORIES, denominators_acq) ] return collections.OrderedDict([ ('name', n), ('test', test), ] + numerators_acq + denominators_acq)
def _reproj_and_clip_vector(srcpath, dstpath): print("Transforming: {}".format(srcpath), flush=True) if os.path.isfile(dstpath): print(" {} already exits".format(dstpath), flush=True) return with buzz.Env(significant=10, allow_complex_footprint=True): ds = buzz.Dataset(sr_work='WGS84', analyse_transformation=False) ds.open_vector('src', srcpath, driver='GeoJSON') ds.open_raster('raster', rgb_wgs84_path) ds.create_vector( 'dst', dstpath, 'polygon', driver='ESRI Shapefile', sr=EPSG29100, ) # Iterate over all geoJSON geometries overlapping with raster # Ignoring geoJSON fields # Save all polygons to Shapefile for geom in ds.src.iter_data(None, mask=ds.raster.fp, clip=True): if isinstance(geom, shapely.geometry.Polygon): ds.dst.insert_data(geom) elif isinstance(geom, shapely.geometry.MultiPolygon): for poly in geom.geoms: ds.dst.insert_data(poly) print("Transformed: {}\n to: {}".format(srcpath, dstpath), flush=True)
def test_init_edge_cases(fps): # rotation aff = Affine.translation(42, 21) * Affine.rotation(12) * Affine.scale(0.1, -0.1) with buzz.Env(allow_complex_footprint=True): buzz.Footprint(gt=aff.to_gdal(), rsize=[1, 1]) # missing parameters with pytest.raises(ValueError): buzz.Footprint(tl=fps.A.tl, size=fps.A.size) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize, size=fps.A.size) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize, tl=fps.A.tl) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize) # shapes with pytest.raises(ValueError, match='shape'): buzz.Footprint(rsize=[], tl=fps.A.tl, size=fps.A.size) with pytest.raises(ValueError, match='shape'): buzz.Footprint(rsize=fps.A.rsize, tl=[], size=fps.A.size) with pytest.raises(ValueError, match='shape'): buzz.Footprint(rsize=fps.A.rsize, tl=fps.A.tl, size=[]) with pytest.raises(ValueError, match='shape'): buzz.Footprint(rsize=fps.A.rsize, gt=[]) # finitude with pytest.raises(ValueError): buzz.Footprint(rsize=[-1] * 2, tl=fps.A.tl, size=fps.A.size) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize, tl=[np.inf] * 2, size=fps.A.size) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize, tl=fps.A.tl, size=[np.inf] * 2) with pytest.raises(ValueError): buzz.Footprint(rsize=fps.A.rsize, gt=[np.inf] * 6)
def test_move(fps1px): fps = fps1px with buzz.Env(warnings=False, allow_complex_footprint=True): # Test the `warnings` deprecation assert fpeq( fps.B, fps.A.move(fps.B.tl), fps.B.move(fps.B.tl), fps.C.move(fps.B.tl), fps.A.move(fps.B.tl, fps.B.tr), fps.B.move(fps.B.tl, fps.B.tr), fps.C.move(fps.B.tl, fps.B.tr), fps.A.move(fps.B.tl, fps.B.tr, fps.B.br), fps.B.move(fps.B.tl, fps.B.tr, fps.B.br), fps.C.move(fps.B.tl, fps.B.tr, fps.B.br), ) aff = ( Affine.translation(*fps.A.bl) * Affine.rotation(45) * Affine.scale(2**0.5, 2**0.5 * -2) ) assert fpeq( buzz.Footprint(gt=aff.to_gdal(), rsize=(1, 1)), fps.A.move(fps.A.bl, fps.A.tr, fps.I.tr), fps.B.move(fps.A.bl, fps.A.tr, fps.I.tr), fps.C.move(fps.A.bl, fps.A.tr, fps.I.tr), ) with pytest.raises(ValueError, match='angle'): fps.C.move(fps.A.bl, fps.A.tr, fps.I.c)
def test_binary_predicates(fps): for fp in fps.values(): assert fp.share_area(fps.AI) assert fp.same_grid(fps.AI) sq2 = 2 ** 0.5 assert not fp.same_grid(fp.move([sq2, sq2])) with buzz.Env(allow_complex_footprint=True): assert not fp.same_grid(fp.move([sq2, sq2], [2 * sq2, 2 * sq2]))
def work(i): j = i % 9 + 1 assert buzz.env.significant == 42 with buzz.Env(significant=j): assert buzz.env.significant == j time.sleep(np.random.rand() / 100) assert buzz.env.significant == j assert buzz.env.significant == 42
def test_thread_pool(): with buzz.Env(significant=42): with ThreadPoolExecutor(10) as ex: it = ex.map( work, range(100), ) list(it)
def test_reproj(): sr0 = SRS[0] sr1 = SRS[3] with buzz.Env(significant=8, allow_complex_footprint=1, warnings=0): # Create `twos`, a recipe from `sr1` to `sr0` # `fp` in sr0 # `ds.wkt` in sr0 # `twos.fp` in sr0 # `twos.fp_origin` in sr1 # `pxfun@fp` in sr1 fp = buzz.Footprint( tl=(sr0['cx'], sr0['cy']), size=(2, 2), rsize=(20, 20), ) ds = buzz.DataSource(sr0['wkt']) def pxfun(fp): assert (twos.fp_origin & fp) == fp, 'fp should be aligned and within twos.fp' return ones.get_data(fp=fp) * 2 twos = ds.create_recipe_araster(pxfun, fp, 'float32', sr=sr1['wkt'], band_schema={'nodata': 42}) # Create `ones`, a raster from `sr1` to `sr1` # `ds2.wkt` in sr1 # `ones.fp` in sr1 # `ones.fp_origin` in sr1 ds2 = buzz.DataSource(sr1['wkt']) ones = ds2.create_araster('', twos.fp_origin, 'float32', 1, driver='MEM', sr=sr1['wkt'], band_schema={'nodata': 42}) ones.fill(1) # Test that `sr1` performs reprojection of `fp` before sending it to `pxfun` assert ones.fp == ones.fp_origin, 'ones has no reproj' assert twos.fp_origin == ones.fp_origin assert ones.dtype == twos.dtype tiles = fp.tile_count( 3, 3, boundary_effect='shrink').flatten().tolist() + [fp] for tile in tiles: assert (twos.get_data(fp=tile) == 2).all() twos.close() ones.close()
def pytest_generate_tests(metafunc): with buzz.Env(significant=15): metafunc.parametrize( argnames='fp', argvalues=[ FP1, FP1.move((-FP1.diagvec / 2)), FP1.move((1e8, 1e8)), FP1.move((1e8, 1e8), (1e8 + 1, 1e8), (1e8 + 1, 1e8 - 1)), ], )
def test_mode4(fps, shp1_path, tif1_path, random_path_shp, random_path_tif, env): wkt_origin = buzz.srs.wkt_of_file(tif1_path) wkt_work = buzz.srs.wkt_of_file(tif1_path, center=True) ds = buzz.DataSource(wkt_work, sr_origin=wkt_origin) ds.open_raster('rast', tif1_path) ds.open_vector('poly', shp1_path) with buzz.Env(allow_complex_footprint=True): ds.create_avector(random_path_shp, 'polygon', [], sr=None).close() ds.create_araster(random_path_tif, fps.AI, 'int32', 1, {}, sr=None).close() fp_poly = buzz.Footprint.of_extent(ds.poly.extent, ds.rast.fp.scale) fp_poly_origin = buzz.Footprint.of_extent(ds.poly.extent_origin, ds.rast.fp_origin.scale) assert fpeq( ds.rast.fp, fp_poly, ) assert fpeq( ds.rast.fp_origin, fps.AI, fp_poly_origin, ) rast = ds.rast.get_data() def f(x, y, z=None): return np.around(x, 6), np.around(y, 6) for i, letter in enumerate(string.ascii_uppercase[:9]): poly = ds.poly.get_data(i, None) raster_polys = ds.rast.fp.find_polygons(rast == ord(letter)) assert len(raster_polys) == 1 raster_poly = raster_polys[0] del raster_polys poly = shapely.ops.transform(f, poly) raster_poly = shapely.ops.transform(f, poly) assert (poly ^ raster_poly).is_empty
def env(): np.set_printoptions(linewidth=400, threshold=np.iinfo('int64').max, suppress=True) with buzz.Env(allow_complex_footprint=1): yield
def env(): with buzz.Env(significant=8): yield
def test_mode2(fps, shp1_path, tif1_path, shp2_path, tif2_path, random_path_shp, random_path_tif, env): ds = buzz.DataSource(sr_work=SR1['wkt']) ds.open_raster('rast1', tif1_path) ds.open_vector('poly1', shp1_path) ds.open_raster('rast2', tif2_path) ds.open_vector('poly2', shp2_path) # Test file creation without spatial reference with buzz.Env(allow_complex_footprint=True): with pytest.raises(ValueError, match='spatial refe'): ds.create_avector(random_path_shp, 'polygon', [], sr=None) with pytest.raises(ValueError, match='spatial refe'): ds.create_araster(random_path_tif, fps.AI, 'int32', 1, {}, sr=None) # Test foorprints equality assert fpeq( fps.AI, ds.rast1.fp, ds.rast1.fp_origin, buzz.Footprint.of_extent(ds.poly1.extent, fps.AI.scale), ds.rast2.fp_origin, ) assert fpeq( ds.rast2.fp, buzz.Footprint.of_extent(ds.poly2.extent, fps.AI.scale), ) assert ds.rast2.fp != ds.rast1.fp # Test file creation with/without conversion of footprint with buzz.Env(allow_complex_footprint=True): with ds.create_araster(random_path_tif, fps.AI, 'int32', 1, sr=SR1['wkt']).delete as r: assert fpeq(fps.AI, r.fp, r.fp_origin) with ds.create_araster(random_path_tif, fps.AI, 'int32', 1, sr=SR2['wkt']).delete as r: assert fpeq( fps.AI, r.fp, ) assert fps.AI != r.fp_origin # Test what's written in rast1/poly1 files rast1 = ds.rast1.get_data() def f(x, y, z=None): return np.around(x, 6), np.around(y, 6) for i, letter in enumerate(string.ascii_uppercase[:9]): poly1 = ds.poly1.get_data(i, None) raster1_polys = ds.rast1.fp.find_polygons(rast1 == ord(letter)) assert len(raster1_polys) == 1 raster1_poly = raster1_polys[0] del raster1_polys poly1 = shapely.ops.transform(f, poly1) raster1_poly = shapely.ops.transform(f, poly1) assert (poly1 ^ raster1_poly).is_empty
def test_corner_cases(fps1px): fps = fps1px with pytest.raises(ValueError): fps.A.intersection() with pytest.raises(ValueError): fps.A.intersection(fps.A, hello=True) with pytest.raises(TypeError): fps.A.intersection(42) assert fpeq( fps.BH, fps.AH.intersection(_FtPoly(fps.BI.__geo_interface__)), ) with pytest.raises(ValueError): fps.A.intersection(fps.A, scale='hello') with pytest.raises(ValueError): fps.A.intersection(fps.A, rotation='hello') with pytest.raises(ValueError): fps.A.intersection(fps.A, alignment='hello') # reso assert fpeq( buzz.Footprint(rsize=[2, 6], size=fps.BH.size, tl=fps.BH.tl), fps.AH.intersection(fps.BI, scale=0.5), fps.AH.intersection(fps.BI, scale=[0.5, -0.5]), fps.AH.intersection(fps.BI, scale=[0.5]), ) with pytest.raises(ValueError): fps.AH.intersection(fps.BI, scale=[]) with pytest.raises(ValueError): fps.AH.intersection(fps.BI, scale=0) lowest = fps.BH.intersection(fps.BH, scale=0.5) highest = fps.BH.intersection(fps.BH, scale=1.0) assert fpeq( lowest, lowest.intersection(highest, scale='lowest'), highest.intersection(lowest, scale='lowest'), ) assert fpeq( highest, highest.intersection(lowest, scale='highest'), lowest.intersection(highest, scale='highest'), ) # rot / align assert fpeq( fps.BH, fps.AH.intersection(fps.BI, rotation=0), fps.AH.intersection(fps.BI, alignment=fps.BH.tl), ) with pytest.raises(ValueError): fps.AH.intersection(fps.BI, alignment=[]) assert fpeq( buzz.Footprint(rsize=[1 + 1, 3 + 1], size=fps.BH.size * [2 / 1, 4 / 3], tl=fps.BH.tl - [0.5, -0.5]), fps.BH.intersection(fps.BH, alignment=[0.5, 0.5]), ) assert fpeq( fps.BH, fps.BH.intersection(fps.BH, alignment='tl'), ) with buzz.Env(allow_complex_footprint=True): for angle in np.r_[0:180:13j]: rotated = fps.E.intersection(fps.E, rotation=angle) nofit = angle % 90 != 0 if nofit: assert tuple(rotated.rsize) == (2, 2) else: assert tuple(rotated.rsize) == (1, 1) assert all(np.around(rotated.scale, 3) == (1, -1)) assert np.around(rotated.angle, 3) == angle diff = rotated.poly - fps.E.poly if nofit: assert np.around(diff.area, 3) == 3.0 else: assert np.around(diff.area, 3) == 0.0 dot = np.dot(fps.E.lrvec / fps.E.w, rotated.lrvec / rotated.w) angle_real = np.arccos(dot) / np.pi * 180 assert np.around(angle_real) == angle # h**o assert fpeq( fps.BH, fps.BH.intersection(fps.BH, homogeneous=True), ) with pytest.raises(ValueError, match='grid'): fps.BH.intersection( fps.BH.intersection(fps.BH, scale=0.5), homogeneous=True, ) with pytest.raises(ValueError, match='grid'): fps.BH.intersection( fps.BH.intersection(fps.BH, alignment=[0.5, 0.5]), homogeneous=True, ) with buzz.Env(allow_complex_footprint=True): with pytest.raises(ValueError, match='grid'): fps.AH.intersection( fps.E.intersection(fps.E, rotation=42), homogeneous=True, ) # fit stripe = sg.Polygon([fps.A.tr, fps.I.tr, fps.I.bl, fps.A.bl]) assert fpeq( fps.AI, fps.AI.intersection(stripe), fps.AI.intersection(stripe, rotation=0), ) with buzz.Env(allow_complex_footprint=True): assert fpeq( fps.AI.intersection(stripe, rotation='fit'), fps.AI.intersection(stripe, rotation=45), ) # misc with pytest.raises(ValueError, match='touch'): fps.A.intersection(fps.B) with pytest.raises(ValueError, match='empty'): fps.A.intersection(fps.C) with pytest.raises(ValueError, match='touch'): fps.A.intersection(fps.D)
def test_mode4(fps, shp1_path, tif1_path, shp2_path, tif2_path, shp3_path, tif3_path, random_path_shp, random_path_tif, env): ds = buzz.Dataset(sr_work=SR1['wkt'], sr_forced=SR2['wkt']) ds.open_raster('tif1', tif1_path) ds.open_vector('shp1', shp1_path) ds.open_raster('tif2', tif2_path) ds.open_vector('shp2', shp2_path) ds.open_raster('tif3', tif3_path) ds.open_vector('shp3', shp3_path) # Test file creation without spatial reference with buzz.Env(allow_complex_footprint=True): with ds.acreate_vector(random_path_shp, 'polygon', [], sr=None).close as r: assert r.wkt_stored == None assert sreq(r.wkt_virtual, SR2['wkt']) with ds.acreate_raster(random_path_tif, fps.AI, 'int32', 1, {}, sr=None).close as v: assert v.wkt_stored == None assert sreq(v.wkt_virtual, SR2['wkt']) # Test SR equality assert sreq( ds.wkt, ds.proj4, ds.tif1.wkt_stored, ds.tif1.proj4_stored, ds.shp1.wkt_stored, ds.shp1.proj4_stored, ) assert sreq( ds.tif1.wkt_virtual, ds.tif1.proj4_virtual, ds.shp1.wkt_virtual, ds.shp1.proj4_virtual, ds.tif2.wkt_virtual, ds.tif2.proj4_virtual, ds.shp2.wkt_virtual, ds.shp2.proj4_virtual, ds.tif2.wkt_stored, ds.tif2.proj4_stored, ds.shp2.wkt_stored, ds.shp2.proj4_stored, ds.tif3.wkt_virtual, ds.tif3.proj4_virtual, ds.shp3.wkt_virtual, ds.shp3.proj4_virtual, ) assert not sreq(ds.tif1.wkt_stored, ds.tif2.wkt_stored) assert (None == ds.tif3.wkt_stored == ds.tif3.proj4_stored == ds.shp3.wkt_stored == ds.shp3.proj4_stored) # Test foorprints equality assert fpeq( fps.AI, # tif/shp 1 ds.tif1.fp_origin, buzz.Footprint.of_extent(ds.shp1.extent_stored, fps.AI.scale), buzz.Footprint.of_extent(ds.shp1.bounds_stored[[0, 2, 1, 3]], fps.AI.scale), # tif/shp 2 ds.tif2.fp_origin, buzz.Footprint.of_extent(ds.shp2.extent_stored, fps.AI.scale), buzz.Footprint.of_extent(ds.shp2.bounds_stored[[0, 2, 1, 3]], fps.AI.scale), # tif/shp 3 ds.tif3.fp_origin, buzz.Footprint.of_extent(ds.shp3.extent_stored, fps.AI.scale), buzz.Footprint.of_extent(ds.shp3.bounds_stored[[0, 2, 1, 3]], fps.AI.scale), ) assert fpeq( # tif/shp 1 ds.tif1.fp, buzz.Footprint.of_extent(ds.shp1.extent, fps.AI.scale), buzz.Footprint.of_extent(ds.shp1.bounds[[0, 2, 1, 3]], fps.AI.scale), # tif/shp 2 ds.tif2.fp, buzz.Footprint.of_extent(ds.shp2.extent, fps.AI.scale), buzz.Footprint.of_extent(ds.shp2.bounds[[0, 2, 1, 3]], fps.AI.scale), # tif/shp 3 ds.tif3.fp, buzz.Footprint.of_extent(ds.shp3.extent, fps.AI.scale), buzz.Footprint.of_extent(ds.shp3.bounds[[0, 2, 1, 3]], fps.AI.scale), ) assert ds.tif1.fp != ds.tif1.fp_stored # Test what's written in all 6 files tif1 = ds.tif1.get_data() tif2 = ds.tif2.get_data() tif3 = ds.tif3.get_data() assert np.all(tif1 == tif2) assert np.all(tif1 == tif3) def f(x, y, z=None): return np.around(x, 6), np.around(y, 6) for i, letter in enumerate(string.ascii_uppercase[:9]): # tif/shp 1 shp1 = ds.shp1.get_data(i, None) shp1 = shapely.ops.transform(f, shp1) raster1_polys = ds.tif1.fp.find_polygons(tif1 == ord(letter)) assert len(raster1_polys) == 1 raster1_poly = raster1_polys[0] raster1_poly = shapely.ops.transform(f, shp1) assert (shp1 ^ raster1_poly).is_empty # tif/shp 2 shp2 = ds.shp2.get_data(i, None) shp2 = shapely.ops.transform(f, shp2) raster2_polys = ds.tif2.fp.find_polygons(tif2 == ord(letter)) assert len(raster2_polys) == 1 raster2_poly = raster2_polys[0] raster2_poly = shapely.ops.transform(f, shp2) assert (shp2 ^ raster2_poly).is_empty # tif/shp 3 shp3 = ds.shp3.get_data(i, None) shp3 = shapely.ops.transform(f, shp3) raster3_polys = ds.tif3.fp.find_polygons(tif3 == ord(letter)) assert len(raster3_polys) == 1 raster3_poly = raster3_polys[0] raster3_poly = shapely.ops.transform(f, shp3) assert (shp3 ^ raster3_poly).is_empty
def test_mode2(fps, shp1_path, tif1_path, shp2_path, tif2_path, shp3_path, tif3_path, random_path_shp, random_path_tif, env): ds = buzz.Dataset(sr_work=SR1['wkt']) ds.open_raster('tif1', tif1_path) ds.open_vector('shp1', shp1_path) ds.open_raster('tif2', tif2_path) ds.open_vector('shp2', shp2_path) # Test file creation/opening without spatial reference with buzz.Env(allow_complex_footprint=True): with pytest.raises(ValueError, match='spatial refe'): ds.acreate_vector(random_path_shp, 'polygon', [], sr=None) with pytest.raises(ValueError, match='spatial refe'): ds.acreate_raster(random_path_tif, fps.AI, 'int32', 1, {}, sr=None) with pytest.raises(ValueError, match='spatial refe'): ds.aopen_raster(tif3_path) with pytest.raises(ValueError, match='spatial refe'): ds.aopen_vector(shp3_path) # Test SR equality assert sreq( ds.wkt, ds.proj4, ds.tif1.wkt_virtual, ds.tif1.wkt_stored, ds.tif1.proj4_virtual, ds.tif1.proj4_stored, ds.shp1.wkt_virtual, ds.shp1.wkt_stored, ds.shp1.proj4_virtual, ds.shp1.proj4_stored, ) assert sreq( ds.tif2.wkt_virtual, ds.tif2.proj4_virtual, ds.shp2.wkt_virtual, ds.shp2.proj4_virtual, ds.tif2.wkt_stored, ds.tif2.proj4_stored, ds.shp2.wkt_stored, ds.shp2.proj4_stored, ) assert not sreq(ds.tif1.wkt_stored, ds.tif2.wkt_stored) # Test foorprints equality assert fpeq( fps.AI, # tif/shp 1 ds.tif1.fp, ds.tif1.fp_origin, buzz.Footprint.of_extent(ds.shp1.extent, fps.AI.scale), buzz.Footprint.of_extent(ds.shp1.extent_stored, fps.AI.scale), buzz.Footprint.of_extent(ds.shp1.bounds[[0, 2, 1, 3]], fps.AI.scale), buzz.Footprint.of_extent(ds.shp1.bounds_stored[[0, 2, 1, 3]], fps.AI.scale), # tif/shp 2 ds.tif2.fp_origin, buzz.Footprint.of_extent(ds.shp2.extent_stored, fps.AI.scale), buzz.Footprint.of_extent(ds.shp2.bounds_stored[[0, 2, 1, 3]], fps.AI.scale), ) assert fpeq( ds.tif2.fp, buzz.Footprint.of_extent(ds.shp2.extent, fps.AI.scale), buzz.Footprint.of_extent(ds.shp2.bounds[[0, 2, 1, 3]], fps.AI.scale), ) assert ds.tif2.fp != ds.tif1.fp # Test file creation with/without conversion of footprint with buzz.Env(allow_complex_footprint=True): with ds.acreate_raster(random_path_tif, fps.AI, 'int32', 1, sr=SR1['wkt'], ow=1).delete as r: assert fpeq(fps.AI, r.fp, r.fp_origin) with ds.acreate_raster(random_path_tif, fps.AI, 'int32', 1, sr=SR2['wkt'], ow=1).delete as r: assert fpeq( fps.AI, r.fp, ) assert fps.AI != r.fp_origin # Test what's written in all 4 files tif1 = ds.tif1.get_data() tif2 = ds.tif2.get_data() assert np.all(tif1 == tif2) def f(x, y, z=None): return np.around(x, 6), np.around(y, 6) for i, letter in enumerate(string.ascii_uppercase[:9]): # tif/shp 1 shp1 = ds.shp1.get_data(i, None) shp1 = shapely.ops.transform(f, shp1) raster1_polys = ds.tif1.fp.find_polygons(tif1 == ord(letter)) assert len(raster1_polys) == 1 raster1_poly = raster1_polys[0] raster1_poly = shapely.ops.transform(f, shp1) assert (shp1 ^ raster1_poly).is_empty # tif/shp 2 shp2 = ds.shp2.get_data(i, None) shp2 = shapely.ops.transform(f, shp2) raster2_polys = ds.tif2.fp.find_polygons(tif2 == ord(letter)) assert len(raster2_polys) == 1 raster2_poly = raster2_polys[0] raster2_poly = shapely.ops.transform(f, shp2) assert (shp2 ^ raster2_poly).is_empty
def env(request): with buzz.Env(significant=request.param): yield request.param
fp, arr, )) return # The NEXT features are not yet implemented # Test 4 - Colorize mandelbrot 100mpx ************************************ ** ds.create_raster_recipe( 'mand_red', fp=fp, dtype='uint8', channel_count=3, compute_array=colorize_mandelbrot, queue_data_per_primitive={'mand': ds.mand_100mpx.queue_data}, computation_tiles=computation_tiling, automatic_remapping=False, ) example_tools.show_several_images(( 'part of mandelbrot 10 mega pixels in red', fp, ds.mand_red.get_data(fp=fp), )) if __name__ == '__main__': if os.path.isdir(CACHE_DIR): for path in example_tools.list_cache_files_path_in_dir(CACHE_DIR): os.remove(path) with buzz.Env(allow_complex_footprint=True): example()