diff --git a/city_metrix/layers/__init__.py b/city_metrix/layers/__init__.py index 669e727..7e5e19e 100644 --- a/city_metrix/layers/__init__.py +++ b/city_metrix/layers/__init__.py @@ -19,3 +19,4 @@ from .alos_dsm import AlosDSM from .overture_buildings import OvertureBuildings from .nasa_dem import NasaDEM +from .impervious_surface import ImperviousSurface diff --git a/city_metrix/layers/impervious_surface.py b/city_metrix/layers/impervious_surface.py new file mode 100644 index 0000000..74e624d --- /dev/null +++ b/city_metrix/layers/impervious_surface.py @@ -0,0 +1,23 @@ +from dask.diagnostics import ProgressBar +import xarray as xr +import xee +import ee + +from .layer import Layer, get_utm_zone_epsg, get_image_collection + + +class ImperviousSurface(Layer): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def get_data(self, bbox): + # load impervious_surface + dataset = ee.ImageCollection(ee.Image("Tsinghua/FROM-GLC/GAIA/v10").gt(0)) # change_year_index is zero if permeable as of 2018 + imperv_surf = ee.ImageCollection(dataset + .filterBounds(ee.Geometry.BBox(*bbox)) + .select('change_year_index') + .sum() + ) + + data = get_image_collection(imperv_surf, bbox, 100, "imperv surf") + return data.change_year_index diff --git a/tests/test_layers.py b/tests/test_layers.py index bfcf4a0..27cb7c5 100644 --- a/tests/test_layers.py +++ b/tests/test_layers.py @@ -9,6 +9,7 @@ EsaWorldCover, EsaWorldCoverClass, HighLandSurfaceTemperature, + ImperviousSurface, LandsatCollection2, LandSurfaceTemperature, NasaDEM, @@ -82,6 +83,11 @@ def test_high_land_surface_temperature(): assert data.any() +def test_impervious_surface(): + data = ImperviousSurface().get_data(BBOX) + assert data.any() + + def test_land_surface_temperature(): mean_lst = LandSurfaceTemperature().get_data(BBOX).mean() assert mean_lst