Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader resampling_method has no effect when doing Reprojection #647

Closed
vincentsarago opened this issue Oct 18, 2023 Discussed in #646 · 2 comments · Fixed by #648
Closed

Reader resampling_method has no effect when doing Reprojection #647

vincentsarago opened this issue Oct 18, 2023 Discussed in #646 · 2 comments · Fixed by #648

Comments

@vincentsarago
Copy link
Member

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:
image
... regardless of the value provided in resampling_method.

Earlier versions of rio-tiler would have produced something like:
image

@vincentsarago
Copy link
Member Author

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)

vrt_transform, vrt_width, vrt_height = get_vrt_transform(
src_dst,
bounds,
height=height,
width=width,
dst_crs=dst_crs,
)

Because the VRT will be of the same size as the desired output, there will be no downscaling/upscaling happening there

resampling=io_resampling,

which is why the resampling_method will have no effect 😭

@vincentsarago
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant