From 364bc21dbbbd64e55fcccbd4d3ca98ce61a9b5c6 Mon Sep 17 00:00:00 2001 From: weiqi-tori Date: Tue, 28 May 2024 19:32:20 +0800 Subject: [PATCH 1/2] add ALOS DSM layer --- city_metrix/layers/alos_dsm.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 city_metrix/layers/alos_dsm.py diff --git a/city_metrix/layers/alos_dsm.py b/city_metrix/layers/alos_dsm.py new file mode 100644 index 0000000..95187e6 --- /dev/null +++ b/city_metrix/layers/alos_dsm.py @@ -0,0 +1,21 @@ +import ee +import xee +import xarray as xr + +from .layer import Layer, get_image_collection + + +class AlosDSM(Layer): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def get_data(self, bbox): + dataset = ee.ImageCollection("JAXA/ALOS/AW3D30/V3_2") + alos_dsm = ee.ImageCollection(dataset + .filterBounds(ee.Geometry.BBox(*bbox)) + .select('DSM') + .mean() + ) + data = get_image_collection(alos_dsm, bbox, 30, "ALOS DSM").DSM + + return data From 925e3428ff522f072da102e4086b9f484d1ef531 Mon Sep 17 00:00:00 2001 From: Chris Rowe Date: Thu, 30 May 2024 15:22:05 +0000 Subject: [PATCH 2/2] test_AlosDSM --- city_metrix/layers/__init__.py | 1 + tests/layers.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/city_metrix/layers/__init__.py b/city_metrix/layers/__init__.py index 3ece2ef..bef56c3 100644 --- a/city_metrix/layers/__init__.py +++ b/city_metrix/layers/__init__.py @@ -15,3 +15,4 @@ from .average_net_building_height import AverageNetBuildingHeight from .open_buildings import OpenBuildings from .tree_canopy_hight import TreeCanopyHeight +from .alos_dsm import AlosDSM diff --git a/tests/layers.py b/tests/layers.py index fb8aa50..ce9fc3f 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 +from city_metrix.layers import LandsatCollection2, Albedo, LandSurfaceTemperature, EsaWorldCover, EsaWorldCoverClass, TreeCover, AverageNetBuildingHeight, OpenStreetMap, OpenStreetMapClass, UrbanLandUse, OpenBuildings, TreeCanopyHeight, AlosDSM from city_metrix.layers.layer import get_image_collection from .conftest import MockLayer, MockMaskLayer, ZONES, LARGE_ZONES, MockLargeLayer @@ -93,4 +93,8 @@ def test_openbuildings(): def test_tree_canopy_hight(): count = TreeCanopyHeight().get_data(SAMPLE_BBOX).count() - assert count \ No newline at end of file + assert count + +def test_AlosDSM(): + mean = AlosDSM().get_data(SAMPLE_BBOX).mean() + assert mean