Re: can resampling not populate cell if source has nodata?

Sean Gillies
 

Hi Nick,

Ignoring nodata values is the default behavior for rasterio, as it is for the GDAL library that rasterio uses. Here's an example using one of rasterio's test files.

$ rio insp tests/data/RGB.byte.tif
Rasterio 1.1.5dev Interactive Inspector (Python 3.6.6)
Type "src.meta", "src.read(1)", or "help(src)" for more information.
>>> show(src.read())

That command uses matplotlib to display the raw data and I've zoomed in to the bottom to show the hard edge along the image collar. Valid data on the inside, nodata on the outside.

Figure_1.png
Now, I'll dilate the image by a factor of 3 on reading and use bilinear resampling to fill in the extra pixels.

>>> from rasterio.enums import Resampling
>>> resampled = src.read(out_shape=(3, src.height * 3, src.width * 3), resampling=Resampling.bilinear)
>>> show(resampled)

Zooming in again to the collar, you can see that the valid data has been smoothed, but the hard nodata edge remains. Nodata values were ignored by the resampling system.
Figure_2.png

On Tue, May 26, 2020 at 11:30 AM <nick.forfinski@...> wrote:
Hi rasterio.  New user here.  Thanks for a fantastic module.  During resampling, is there a way to force the cells of the resampled raster to nodata if any of the corresponding original cells are nodata?   (If by chance anyone is familiar with it, I'm looking for functionality analogous to arcpy's Aggregate function with ignore_data=True https://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/aggregate.htm )

Thanks,
Nick



--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.