简体   繁体   English

使用 Xarray.where 进行屏蔽会引发错误“维度 'y' 不相等”

[英]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两个栅格具有相同的尺寸,但是当我应用掩码时 xarraydata.where 抛出错误

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

ValueError: indexes along dimension 'y' are not equal ValueError:沿维度“y”的索引不相等

面具

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 的定义中添加扩展名 .data 来解决它

self.rectangle = self._landmask_file.landmask_diff.data

I hope this helps!我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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