Reader `resampling_method` has no effect when doing Reprojection
Closed this issue · 2 comments
Discussed in #646
Originally posted by DanSchoppe October 16, 2023
On the latest release of rio-tiler
(as well as several earlier 6.x releases I've tried), the resampling_method
argument to Reader.tile()
seems to have no effect. I haven't tested whether it affects Reader methods beyond tile()
.
Here's a simple recreation:
from rio_tiler.io import Reader
with Reader('https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/15/T/VK/2023/10/S2B_15TVK_20231008_0_L2A/TCI.tif') as cog:
img = cog.tile(
tile_x=31588,
tile_y=47192,
tile_z=17,
resampling_method="cubic",
)
with open('tile.png', 'wb') as f:
f.write(img.render())
The resulting tile looks like:
... regardless of the value provided in resampling_method
.
Earlier versions of rio-tiler would have produced something like:
From the discussion:
Ooo I think I know what's going on 😬
when we are doing reprojection (using WarpedVRT) we are creating a VRT which is aligned with the bounds
(This is to make sure we fetch the overviews)
Lines 360 to 366 in 775ecfd
Because the VRT will be of the same size as the desired output, there will be no downscaling/upscaling
happening there
Line 226 in 775ecfd
which is why the resampling_method
will have no effect 😭
@DanSchoppe I think we are good to go with #648
gist: https://gist.github.com/vincentsarago/299c368cfa696dec84511d97709d64a6