From e33f68825184367e5279037a5135e11f124f2554 Mon Sep 17 00:00:00 2001 From: Chris Rowe Date: Tue, 28 May 2024 21:54:21 -0400 Subject: [PATCH] add TreeCanopyHeight function --- city_metrix/layers/__init__.py | 1 + city_metrix/layers/tree_canopy_hight.py | 29 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 city_metrix/layers/tree_canopy_hight.py diff --git a/city_metrix/layers/__init__.py b/city_metrix/layers/__init__.py index 1869e13..3ece2ef 100644 --- a/city_metrix/layers/__init__.py +++ b/city_metrix/layers/__init__.py @@ -14,3 +14,4 @@ from .built_up_height import BuiltUpHeight from .average_net_building_height import AverageNetBuildingHeight from .open_buildings import OpenBuildings +from .tree_canopy_hight import TreeCanopyHeight diff --git a/city_metrix/layers/tree_canopy_hight.py b/city_metrix/layers/tree_canopy_hight.py new file mode 100644 index 0000000..464c7cf --- /dev/null +++ b/city_metrix/layers/tree_canopy_hight.py @@ -0,0 +1,29 @@ +from .layer import Layer, get_utm_zone_epsg, get_image_collection + +from dask.diagnostics import ProgressBar +import xarray as xr +import xee +import ee + + +class TreeCanopyHeight(Layer): + + name = "tree_canopy_hight" + + NO_DATA_VALUE = 0 + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def get_data(self, bbox): + canopy_ht = ee.ImageCollection("projects/meta-forest-monitoring-okw37/assets/CanopyHeight") + # aggregate time series into a single image + canopy_ht = canopy_ht.reduce(ee.Reducer.mean()).rename("cover_code") + + + + + data = get_image_collection(ee.ImageCollection(canopy_ht), bbox, 1, "tree canopy hight") + + return data.cover_code +