Skip to content

Commit

Permalink
fill nodata of bright building top as urban (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: Emma Ai <[email protected]>
  • Loading branch information
emmaai and Emma Ai authored Dec 19, 2024
1 parent 0cf4d97 commit 7ca53c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions odc/stats/plugins/lc_level34.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
xx, self.class_def, self.class_condition[class_col], class_col
)

# patch the bright building top, where
# level3 = nodata & artificial_surface = 215 -> artificial_surface (215)

level3 = expr_eval(
"where((a==nodata)&(b==215), 215, a)",
{"a": level3, "b": xx.artificial_surface.data},
name="l3_patch_building_top",
dtype="uint8",
**{"nodata": NODATA},
)

# apply urban mask
# 215 -> 216 if urban_mask == 0
urban_mask = rasterize_vector_mask(
Expand Down Expand Up @@ -146,6 +157,17 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
xx, self.class_def, self.class_condition[class_col], class_col
)

# patch the bright building top, where
# level4 = nodata & level3 = 215 -> artifical_surface(93)

level4 = expr_eval(
"where((a==nodata)&(b==215), 93, a)",
{"a": level4, "b": xx.level3.data},
name="l4_patch_building_top",
dtype="uint8",
**{"nodata": NODATA},
)

data_vars = {
k: xr.DataArray(v, dims=dims, attrs=attrs)
for k, v in zip(self.measurements, [level3.squeeze(), level4.squeeze()])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lc_level34.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def image_groups():
[
[210, 210, 210],
[210, 210, 210],
[223, 210, 210],
[223, 255, 210],
[221, 221, 221],
]
],
Expand Down

0 comments on commit 7ca53c0

Please sign in to comment.