我试图完成类似的事情。但是试图计算两个插值网格之间的差异。网格具有不同的形状,因此不能使用np.subtract来计算差异。有关如何计算差异的任何帮助吗?
#create two interpolated grids from two set of xyz points and calculate difference
ixx = np.array(self.ix)
iyy = np.array(self.iy)
izz = np.array(self.iz)
iminx = min(ixx.flat)
imaxx = max(ixx.flat)
iminy = min(iyy.flat)
imaxy = max(iyy.flat)
# post surface - get extents
pxx = np.array(self.px)
pyy = np.array(self.py)
pzz = np.array(self.pz)
pminx = min(pxx.flat)
pmaxx = max(pxx.flat)
pminy = min(pyy.flat)
pmaxy = max(pyy.flat)
ixi = np.arange(iminx, imaxx, self.cellsize)
iyi = np.arange(iminy, imaxy, self.cellsize)
iX,iY = np.meshgrid(ixi,iyi)
iextent = (min(ixi), max(ixi), min(iyi), max(iyi))
pxi = np.arange(pminx, pmaxx, self.cellsize)
pyi = np.arange(pminy, pmaxy, self.cellsize)
pX,pY = np.meshgrid(pxi,pyi)
pextent = (min(pxi), max(pxi), min(pyi), max(pyi))
igrid = griddata((ixx, iyy), izz, (iX, iY), method='linear')
pgrid = griddata((pxx, pyy), pzz, (pX, pY), method='linear')
# would like to calcualte difference, but this wont work, due to different shapes
changegrid = np.subtract(pgrid, igrid)
igrid形状是(181,130),pgrid形状是(184,126)。
另一个重要信息是这些是具有重叠空间范围的空间网格。如果我们只是广播/扩展数组形状,那就足够了吗?我不想在错误的x / y位置减去网格。所以基本上就像在GIS / Arcmap中我们如何计算特定xy单元位置的每个单元格的栅格差异。