Skip to content

Commit

Permalink
Merge pull request #46 from wri/add_max_tree_cover_to_tree_cover
Browse files Browse the repository at this point in the history
add max_tree_cover to get_data()
  • Loading branch information
weiqi-tori authored Jun 14, 2024
2 parents db16303 + 0f8506f commit d29ee3f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion city_metrix/layers/tree_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ 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
self.max_tree_cover = max_tree_cover

def get_data(self, bbox):
tropics = ee.ImageCollection('projects/wri-datalab/TropicalTreeCover')
Expand All @@ -27,6 +28,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

0 comments on commit d29ee3f

Please sign in to comment.