Closed camiloramirezgo closed 1 year ago
We have nan in the mask:
But according to the documentation it should only be 0s and 1s? (https://rasterio.readthedocs.io/en/stable/api/rasterio.fill.html)
mask (numpy ndarray or None) – A mask band indicating which pixels to interpolate. Pixels to interpolate into are indicated by the value 0. Values > 0 indicate areas to use during interpolation. Must be same shape as image. This array always takes precedence over the image’s mask (see above). If None, the inverse of the image’s mask will be used if available.
From line 1454 in model.py (or close by depending on what each branch looks like) can we not do the following:
layer = layer.data.copy()
if fill_nodata_method:
mask = layer.copy().astype(float)
mask[mask == nodata] = np.nan
if np.isnan(mask[self.rows, self.cols]).sum() > 0:
mask[~np.isnan(mask)] = 1
base = self.base_layer.data.copy()
base[base == self.base_layer.meta['nodata']] = np.nan
rows, cols = np.where(np.isnan(mask) & ~np.isnan(base))
mask[rows, cols] = 0
mask=np.nan_to_num(mask, 0) <--- ADDED
if fill_nodata_method == 'interpolate':
layer = fillnodata(layer, mask=mask,
max_search_distance=100)
This error is appearing when calling the
raster_to_dataframe
method of themodel.py
, when entering the interpolation method. Apparently, it is caused by the call to thefillnodata()
function of therasterio.fill
module. It happens only in this two places:and![Image](https://user-images.githubusercontent.com/12953752/236511892-43cfa5a0-482c-4d6e-bb53-2b96e3f2b38c.png)