Skip to content

Commit

Permalink
cover the edge cases of landcover level1
Browse files Browse the repository at this point in the history
  • Loading branch information
Emma Ai committed Dec 2, 2024
1 parent 4402dc1 commit ae4f5eb
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions odc/stats/plugins/lc_veg_class_a1.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,26 @@ def l3_class(self, xx: xr.Dataset):
},
)

# all unmarked values (0) is terretrial veg

# all unmarked values (0) and 255 > veg >= 2 is terretrial veg
l3_mask = expr_eval(
"where(a<=0, m, a)",
{"a": l3_mask},
"where((a<=0)&(b>=2)&(b<nodata), m, a)",
{"a": l3_mask, "b": xx["veg_frequency"].data},
name="mark_veg",
dtype="uint8",
**{"m": self.output_classes["terrestrial_veg"]},
**{
"m": self.output_classes["terrestrial_veg"],
"nodata": (
NODATA
if xx["veg_frequency"].attrs["nodata"]
!= xx["veg_frequency"].attrs["nodata"]
else xx["veg_frequency"].attrs["nodata"]
),
},
)

# mark nodata if any source is nodata
# issues:
# - nodata information from non-indexed datasets missing

# Mask nans with NODATA
# Mask nans and pixels where non of classes applicable
l3_mask = expr_eval(
"where((a!=a), nodata, e)",
"where((a!=a)|(e<=0), nodata, e)",
{
"a": si5,
"e": l3_mask,
Expand Down

0 comments on commit ae4f5eb

Please sign in to comment.