Skip to content

Commit

Permalink
update to main
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqi-tori committed Jun 3, 2024
2 parents d053023 + 5217fc0 commit 1bac7af
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 3 deletions.
1 change: 1 addition & 0 deletions city_metrix/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
from .average_net_building_height import AverageNetBuildingHeight
from .open_buildings import OpenBuildings
from .tree_canopy_height import TreeCanopyHeight
from .alos_dsm import AlosDSM
21 changes: 21 additions & 0 deletions city_metrix/layers/alos_dsm.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 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
134 changes: 132 additions & 2 deletions notebooks/tutorial/get layers.ipynb

Large diffs are not rendered by default.

7 changes: 6 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, SmartSurfaceLULC
from city_metrix.layers import LandsatCollection2, Albedo, LandSurfaceTemperature, EsaWorldCover, EsaWorldCoverClass, TreeCover, AverageNetBuildingHeight, OpenStreetMap, OpenStreetMapClass, UrbanLandUse, OpenBuildings, TreeCanopyHeight, AlosDSM, SmartSurfaceLULC
from city_metrix.layers.layer import get_image_collection
from .conftest import MockLayer, MockMaskLayer, ZONES, LARGE_ZONES, MockLargeLayer, MockGroupByLayer, \
MockLargeGroupByLayer
Expand Down Expand Up @@ -104,6 +104,11 @@ def test_openbuildings():
def test_tree_canopy_hight():
count = TreeCanopyHeight().get_data(SAMPLE_BBOX).count()
assert count

def test_AlosDSM():
mean = AlosDSM().get_data(SAMPLE_BBOX).mean()
assert mean


def test_smart_surface_lulc():
count = SmartSurfaceLULC().get_data(SAMPLE_BBOX).count()
Expand Down

0 comments on commit 1bac7af

Please sign in to comment.