From d60d60bbe3646a8b4206f579413c981c46da28f9 Mon Sep 17 00:00:00 2001 From: Ted Wong Date: Fri, 7 Jun 2024 16:10:26 -0400 Subject: [PATCH 1/3] add max_tree_cover to get_data() --- city_metrix/layers/tree_cover.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/city_metrix/layers/tree_cover.py b/city_metrix/layers/tree_cover.py index e5e89c4..1fa3fa0 100644 --- a/city_metrix/layers/tree_cover.py +++ b/city_metrix/layers/tree_cover.py @@ -13,7 +13,7 @@ class TreeCover(Layer): NO_DATA_VALUE = 255 - def __init__(self, min_tree_cover=None, **kwargs): + def __init__(self, min_tree_cover=None, max_tree_cover=None, **kwargs): super().__init__(**kwargs) self.min_tree_cover = min_tree_cover @@ -27,6 +27,8 @@ def get_data(self, bbox): if self.min_tree_cover is not None: data = data.where(data >= self.min_tree_cover) + if self.max_tree_cover is not None: + data = data.where(data <= self.max_tree_cover) return data From 68f413dcb824052d98721c1fce18249088c9dcf3 Mon Sep 17 00:00:00 2001 From: Ted Wong Date: Tue, 11 Jun 2024 11:01:13 -0400 Subject: [PATCH 2/3] fix max_tree_cover --- city_metrix/layers/tree_cover.py | 1 + 1 file changed, 1 insertion(+) diff --git a/city_metrix/layers/tree_cover.py b/city_metrix/layers/tree_cover.py index 1fa3fa0..4c93a06 100644 --- a/city_metrix/layers/tree_cover.py +++ b/city_metrix/layers/tree_cover.py @@ -16,6 +16,7 @@ class TreeCover(Layer): def __init__(self, min_tree_cover=None, max_tree_cover=None, **kwargs): super().__init__(**kwargs) self.min_tree_cover = min_tree_cover + self.max_tree_cover = max_tree_cover def get_data(self, bbox): tropics = ee.ImageCollection('projects/wri-datalab/TropicalTreeCover') From 0f8506f7ec725f007a534c3499251996e6fba6ff Mon Sep 17 00:00:00 2001 From: Ted Wong Date: Tue, 11 Jun 2024 11:32:15 -0400 Subject: [PATCH 3/3] fix max_tree_cover --- city_metrix/layers/tree_cover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/city_metrix/layers/tree_cover.py b/city_metrix/layers/tree_cover.py index 4c93a06..fadc9bb 100644 --- a/city_metrix/layers/tree_cover.py +++ b/city_metrix/layers/tree_cover.py @@ -16,7 +16,7 @@ class TreeCover(Layer): def __init__(self, min_tree_cover=None, max_tree_cover=None, **kwargs): super().__init__(**kwargs) self.min_tree_cover = min_tree_cover - self.max_tree_cover = max_tree_cover + self.max_tree_cover = max_tree_cover def get_data(self, bbox): tropics = ee.ImageCollection('projects/wri-datalab/TropicalTreeCover')