Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nasa DEM #51

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions city_metrix/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions city_metrix/layers/nasa_dem.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion tests/layers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Loading