Skip to content

Commit

Permalink
add tcl mask that was left behind
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-negusse committed Oct 31, 2024
1 parent 57d86bb commit a8ffd95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/routes/titiler/algorithms/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Alerts(BaseAlgorithm):
title: str = "Deforestation Alerts"
description: str = "Decode and visualize alerts"

conf_colors: OrderedDict = None
conf_colors: Optional[OrderedDict] = None

record_start_date: str = "2014-12-31"

Expand Down
11 changes: 6 additions & 5 deletions app/routes/titiler/algorithms/dist_alerts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import OrderedDict
from datetime import datetime
from typing import Optional

from pydantic import ConfigDict
Expand Down Expand Up @@ -53,11 +52,13 @@ def create_mask(self):
)

if self.tree_cover_loss_mask:
# Tree cover loss 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
# is used as source of truth.
mask *= (
self.tree_cover_loss_data.array[0, :, :] >= self.tree_cover_loss_mask
or self.tree_cover_loss_data.array[0, :, :] == 0
or self.tree_cover_loss_data.array[0, :, :]
<= datetime.strptime(self.record_start_date, "%Y-%m-%d").year
(self.tree_cover_loss_data.array[0, :, :] >= self.tree_cover_loss_mask)
| (self.tree_cover_loss_data.array[0, :, :] == 0)
| (self.tree_cover_loss_data.array[0, :, :] <= 2020)
)

return mask

0 comments on commit a8ffd95

Please sign in to comment.