Skip to content

Commit

Permalink
update docs for clarity; add todo comment for version update in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-negusse committed Nov 5, 2024
1 parent 6fe4291 commit 454d840
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions app/routes/titiler/algorithms/dist_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class DISTAlerts(Alerts):
tree_cover_height_mask: Optional[int] = None
tree_cover_height_data: Optional[ImageData] = None

# the highest loss year that is used to exclude alerts for
# the purpose of showing only alerts in forests
tree_cover_loss_mask: Optional[int] = None
tree_cover_loss_data: Optional[ImageData] = None

Expand All @@ -52,11 +54,11 @@ def create_mask(self):
)

if self.tree_cover_loss_mask:
# Tree cover loss data before 2020 can't be used to filter out pixels as not forest
# if they had tree cover loss. Instead, we use tree cover height taken that
# year as source of truth. For example, if a pixel had tree cover loss on
# 2018, but has tree cover height (2020) that meets the forest threshold, the pixel meets
# the forest criteria for alerts.
# Tree cover loss data before 2020 can't be used to filter out pixels as not forest.
# Instead, we use tree cover height taken that year as source of truth.
# For example, if a pixel had tree cover loss in 2018, but has tree cover
# height (2020) that meets the forest threshold, the pixel meets
# the forest criteria for alerts and is not masked out.
mask *= (
self.tree_cover_loss_data.array[0, :, :] > self.tree_cover_loss_mask
) | (self.tree_cover_loss_data.array[0, :, :] <= 2020)
Expand Down
3 changes: 2 additions & 1 deletion app/routes/titiler/umd_glad_dist_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def glad_dist_alerts_raster_tile(
tree_cover_loss_cutoff: bool = Query(
False,
ge=2021,
description="""This filter is to be used on conjunction with `tree_cover_density` and `tree_cover_height` filters to detect only alerts in forests by masking out pixels that have had tree cover loss prior to the alert.""",
description="""This filter is to be used in conjunction with `tree_cover_density` and `tree_cover_height` filters to detect only alerts in forests, by masking out pixels that have had tree cover loss prior to the alert.""",
),
) -> Response:
"""UMD GLAD DIST alerts raster tiles."""
Expand Down Expand Up @@ -99,6 +99,7 @@ async def glad_dist_alerts_raster_tile(
dist_alert.tree_cover_height_data = reader.tile(tile_x, tile_y, zoom)

if tree_cover_loss_cutoff:
# TODO: update to v1.11 in production
with COGReader(
f"s3://{DATA_LAKE_BUCKET}/umd_tree_cover_loss/v1.10.1/raster/epsg-4326/cog/default.tif"
) as reader:
Expand Down

0 comments on commit 454d840

Please sign in to comment.