def _warp(self, geometry, gsd, dem, proj, dtype, buf=0):
transpix = self._transpix(geometry, gsd, dem, proj)
xmin, xmax, ymin, ymax = (int(max(transpix[0,:,:].min() - buf, 0)),
int(min(transpix[0,:,:].max() + buf, self.shape[1])),
int(max(transpix[1,:,:].min() - buf, 0)),
int(min(transpix[1,:,:].max() + buf, self.shape[2])))
transpix[0,:,:] = transpix[0,:,:] - xmin
transpix[1,:,:] = transpix[1,:,:] - ymin
data = self[:,xmin:xmax, ymin:ymax].compute(get=dask.get) # read(quiet=True)
if data.shape[1]*data.shape[2] > 0:
return np.rollaxis(np.dstack([tf.warp(data[b,:,:], transpix, preserve_range=True, order=3, mode="edge") for b in xrange(data.shape[0])]).astype(dtype), 2, 0)
else:
return np.zeros((data.shape[0], transpix.shape[1], transpix.shape[2]))
评论列表
文章目录