diff --git a/city_metrix/layers/__init__.py b/city_metrix/layers/__init__.py index 4af37fb..ea7fa8a 100644 --- a/city_metrix/layers/__init__.py +++ b/city_metrix/layers/__init__.py @@ -17,3 +17,4 @@ from .tree_canopy_height import TreeCanopyHeight from .alos_dsm import AlosDSM from .overture_buildings import OvertureBuildings +from .nasa_dem import NasaDEM diff --git a/city_metrix/layers/nasa_dem.py b/city_metrix/layers/nasa_dem.py new file mode 100644 index 0000000..49b2d13 --- /dev/null +++ b/city_metrix/layers/nasa_dem.py @@ -0,0 +1,21 @@ +import ee +import xee +import xarray as xr + +from .layer import Layer, get_image_collection + + +class NasaDEM(Layer): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def get_data(self, bbox): + dataset = ee.Image("NASA/NASADEM_HGT/001") + nasa_dem = ee.ImageCollection(ee.ImageCollection(dataset) + .filterBounds(ee.Geometry.BBox(*bbox)) + .select('elevation') + .mean() + ) + data = get_image_collection(nasa_dem, bbox, 30, "NASA DEM").elevation + + return data diff --git a/tests/layers.py b/tests/layers.py index 19c6936..620ee89 100644 --- a/tests/layers.py +++ b/tests/layers.py @@ -1,6 +1,6 @@ import ee -from city_metrix.layers import LandsatCollection2, Albedo, LandSurfaceTemperature, EsaWorldCover, EsaWorldCoverClass, TreeCover, AverageNetBuildingHeight, OpenStreetMap, OpenStreetMapClass, UrbanLandUse, OpenBuildings, TreeCanopyHeight, AlosDSM, SmartSurfaceLULC, OvertureBuildings +from city_metrix.layers import LandsatCollection2, Albedo, LandSurfaceTemperature, EsaWorldCover, EsaWorldCoverClass, TreeCover, AverageNetBuildingHeight, OpenStreetMap, OpenStreetMapClass, UrbanLandUse, OpenBuildings, TreeCanopyHeight, AlosDSM, SmartSurfaceLULC, OvertureBuildings, NasaDEM from city_metrix.layers.layer import get_image_collection from .conftest import MockLayer, MockMaskLayer, ZONES, LARGE_ZONES, MockLargeLayer, MockGroupByLayer, \ MockLargeGroupByLayer @@ -116,3 +116,7 @@ def test_smart_surface_lulc(): def test_overture_buildings(): count = OvertureBuildings().get_data(SAMPLE_BBOX).count().sum() assert count + +def test_nasa_dem(): + mean = NasaDEM().get_data(SAMPLE_BBOX).mean() + assert mean