opendatacube / odc-geo

GeoBox and geometry utilities extracted from datacube-core
https://odc-geo.readthedocs.io/en/latest/
Apache License 2.0
74 stars 11 forks source link

Apply spatial mask across non-spatial dimensions #155

Open colinahill opened 1 month ago

colinahill commented 1 month ago

odc.geo.xr.mask fails for xarray.DataArray and xarray.Dataset if they have more than the 2 spatial dimensions of latitude and longitude (or equivalent). As other dimensions are common (e.g. time) it would be convenient to allow spatial masking across all other (non-spatial) dimensions.

This also impacts odc.geo.xr.crop, which uses mask.

robbibt commented 1 month ago

Hye @colinahill, that seems problematic - I'm pretty sure I tested this on multi-temporal data originally. Do you have some simple reproducible example I could try this out on?

Edit: we have code below that successfully applies a mask to multitemporal data, so if this no longer works, it's broken recently. What specific error do you get here? https://knowledge.dea.ga.gov.au/notebooks/How_to_guides/Polygon_drill.html#Mask-data-using-polygon