Open adehecq opened 7 months ago
The issue is caused by the fact that when downsampling, we are rounding up the shape (here).
So when reading the data a few lines below in _load_rio
, an out_shape is given. Because the output is forced to that shape, that is slightly larger than the actual size, it runs a nearest neighbor resampling.
There are two options:
boundless=True
which allows to read beyond the original size and fill with a fill_value. But once again, I believe the window should also be set.
Describe the bug When loading a raster with
geoutils.Raster(filename, downsample=6)
, one can expect that the pixels are sampled every 6 pixels, without interpolation. This is not the case.To Reproduce
The best way to test this, is to create a Raster with data that increases linearly along lines and/or columns. Here I create a raster that has a gradient of 1 along rows and 100 along lines. I save this raster and open it with downsampling option. The gradient of the output should be
1*downsample
along rows and100*downsample
along columns, but when the shape is not a multiple of downsample, it does not work. For example:The output figure is
Expected behavior
The gradient of the downsampled image should be constant.
System (please complete the following information): Irrelevant