def raster_reproject(tmp_path_factory): tmp_path = tmp_path_factory.mktemp("rasters") bounds = rio.warp.transform_bounds(4326, 3035, X0, Y0, X1, Y1) res = 1000 transform, shape = padded_transform_and_shape(bounds, res) mask = np.random.rand(*shape) < raster_clip mask = mask.astype(rio.int32) path = tmp_path / 'raster_reproject.tif' with rio.open(path, 'w', driver='GTiff', transform=transform, crs=3035, width=shape[1], height=shape[0], count=1, dtype=mask.dtype) as dst: dst.write(mask, indexes=1) return path
def raster_codes(tmp_path_factory): tmp_path = tmp_path_factory.mktemp("rasters") bounds = (X0, Y0, X1, Y1) # same as in test_gis.py res = 0.01 transform, shape = padded_transform_and_shape(bounds, res) mask = (np.random.rand(*shape) * 100).astype(int) mask = mask.astype(rio.int32) path = tmp_path / 'raster_codes.tif' with rio.open(path, 'w', driver='GTiff', transform=transform, crs=4326, width=shape[1], height=shape[0], count=1, dtype=mask.dtype) as dst: dst.write(mask, indexes=1) return path
def raster(tmp_path_factory): tmp_path = tmp_path_factory.mktemp("rasters") bounds = (X0, Y0, X1, Y1) # same as in test_gis.py res = 0.01 transform, shape = padded_transform_and_shape(bounds, res) mask = np.random.rand(*shape) < raster_clip mask = mask.astype(rio.int32) path = tmp_path / "raster.tif" with rio.open( path, "w", driver="GTiff", transform=transform, crs=4326, width=shape[1], height=shape[0], count=1, dtype=mask.dtype, ) as dst: dst.write(mask, indexes=1) return path