def test_join_use_mask_band(): # https://github.com/OSGeo/gdal/issues/1148 # The test checks the pixel at the coordinate of bottom left corner of the r2 raster is unmasked. r1 = GeoRaster2.open("tests/data/raster/overlap1.tif") r2 = GeoRaster2.open("tests/data/raster/overlap2.tif") joined = join([r1, r2]) assert not joined.get(r2.corners()["bl"]).mask.all()
def test_chunks_without_pad(raster): shape = (256, 256) # validate we can construct the original raster from the chunks chunks = [r for r, _ in raster.chunks()] merged_raster = join(chunks) assert merged_raster.crs == raster.crs assert merged_raster.affine.almost_equals(raster.affine, precision=1e-3) assert np.array_equal(merged_raster.image, raster.image)
def test_chunks_with_pad(raster): shape = (256, 256) # validate that each chunk is in the right offsets for r, offsets in raster.chunks(shape, pad=True): expected_raster = raster.get_window(Window(col_off=offsets[0], row_off=offsets[ 1], width=shape[0], height=shape[1])) assert r == expected_raster # validate we can construct the original raster from the chunks chunks = [r for r, _ in raster.chunks(pad=True)] merged_raster = join(chunks) assert merged_raster.crs == raster.crs assert merged_raster.affine.almost_equals(raster.affine, precision=1e-3) # raster created has bigger shape cause of the edges assert np.array_equal(merged_raster.image[:, :raster.height, :raster.width], raster.image) # validating the rest is masked assert np.array_equal(merged_raster.image.mask[:, raster.height:, raster.width:].all(), True)
def test_chunks_for_full_raster(raster): chunks = [r for r, _ in raster.chunks(pad=True)] merged_raster = join(chunks) joined_raster_from_256_mult_size = join( [r for r, _ in merged_raster.chunks()]) assert joined_raster_from_256_mult_size.shape == merged_raster.shape