def test_download_masked_geotiff(self): input = self.create_spacetime_layer() polygon = geometry.Polygon([[0, 0], [1.9, 0], [1.9, 1.9], [0, 1.9]]) imagecollection = GeotrellisTimeSeriesImageCollection( gps.Pyramid({0: input}), InMemoryServiceRegistry()) imagecollection = imagecollection.mask(polygon) geotiffs = imagecollection.download( str(self.temp_folder / "test_download_masked_result.geotiff")) print(geotiffs)
def test_mask_raster(self): input = Pyramid({0: self.tiled_raster_rdd}) def createMask(tile): tile.cells[0][0][0] = 0.0 return tile mask_layer = self.tiled_raster_rdd.map_tiles(createMask) mask = Pyramid({0: mask_layer}) imagecollection = GeotrellisTimeSeriesImageCollection( input, InMemoryServiceRegistry()) stitched = imagecollection.mask( rastermask=GeotrellisTimeSeriesImageCollection( mask, InMemoryServiceRegistry()), replacement=10.0).reduce('max', 'temporal').pyramid.levels[0].stitch() print(stitched) self.assertEquals(2.0, stitched.cells[0][0][0]) self.assertEquals(10.0, stitched.cells[0][0][1])
def test_download_masked_geotiff_reproject(self): input = self.create_spacetime_layer() polygon = geometry.Polygon([[0, 0], [1.9, 0], [1.9, 1.9], [0, 1.9]]) import pyproj from shapely.ops import transform from functools import partial project = partial( pyproj.transform, pyproj.Proj(init="EPSG:4326"), # source coordinate system pyproj.Proj(init="EPSG:3857")) # destination coordinate system reprojected = transform(project, polygon) imagecollection = GeotrellisTimeSeriesImageCollection( gps.Pyramid({0: input}), InMemoryServiceRegistry()) imagecollection = imagecollection.mask(reprojected, "EPSG:3857") geotiffs = imagecollection.download( str(self.temp_folder / "test_download_masked_result.3857")) print(geotiffs)