Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add max_tree_cover to get_data() #46

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@weiqi-tori weiqi-tori Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add self.max_tree_cover = max_tree_cover

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that line.

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

Loading