简体   繁体   中英

Masking using Xarray.where throws an error "dimension 'y' are not equal"

I am trying to mask a raster using another raster. Both rasters have same dimensions, but when i apply the mask the xarraydata.where throws error

f[0].where(mask,other=np.nan)

ValueError: indexes along dimension 'y' are not equal

面具

2

I struggled with the same problem for a few hours due to a lack of helpful answers online.

This line:

self.file[var] = self.file[var].where(self.not_rectangle, other=val)

was giving an error similar to yours:

indexes along dimension 'lsmlat' are not equal

I solved it by adding the extension .data in my definition of self.rectangle:

self.rectangle = self._landmask_file.landmask_diff.data

I hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM