-
Hello! I am currently trying to figure out the best way to mask out cloud values in a rioxarray object. The Earth Lab team and I have been updating our lessons to lean more on rioxarray then rasterio, and I got a little stuck on this lesson here about masking cloud values: https://www.earthdatascience.org/courses/use-data-open-source-python/multispectral-remote-sensing/landsat-in-Python/remove-clouds-from-landsat-data/. As you can see in that lesson, currently we do it by just getting the numpy arrays out of the rioxarray objects with
The question boils down to this: is there a way to apply a mask like this to a rioxarray object that doesn't involve turning it into a numpy array? Any insight here would be greatly appreciated, thanks for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Just to maybe clarify a bit more, here's what
|
Beta Was this translation helpful? Give feedback.
-
Looks like xarray also has the isin method. Side note: xarray doesn't support masked arrays, it just converts to float and uses So, the equivalent xarray form would be: all_masked_values = [96, 112, 160, 176, 224]
masked = landsat_pre.where(~landsat_qa.isin(all_masked_values)) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback, that looks great! |
Beta Was this translation helpful? Give feedback.
Looks like xarray also has the isin method.
Side note: xarray doesn't support masked arrays, it just converts to float and uses
nan
ref.So, the equivalent xarray form would be: