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

add warning when trying to create huge VRT #381

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions rio_tiler/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""rio_tiler.utils: utility functions."""

import warnings
from io import BytesIO
from typing import Any, Dict, Optional, Sequence, Tuple, Union

Expand Down Expand Up @@ -206,6 +207,15 @@ def get_vrt_transform(
vrt_height = max(1, round((s - n) / h_res))
vrt_transform = from_bounds(w, s, e, n, vrt_width, vrt_height)

# Warns when the read resolution (tile, part) is lower than the
# resolution of the smaller overview. This will result in rasterio/rio-tiler
# creating a big WarpedVRT and trying to read a small part of it.
Comment on lines +210 to +212
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this in the second line of the warning message as well. Just saying

Trying to fetch lower resolution than min overview resolution

doesn't really tell anything to the user, and as a user I'd be confused why I'm getting warned at.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, TBH I'm still not sure about the warning, I hope I'll be able to find a solution instead 😄

max_ovr_dec = max(src_dst.overviews(1) or [1])
overview_res = max(abs(vrt_transform.a), abs(vrt_transform.e)) * max_ovr_dec
dst_res = max((abs(tile_transform.a), abs(tile_transform.e)))
if overview_res < dst_res:
warnings.warn("Trying to fetch lower resolution than min overview resolution")

return vrt_transform, vrt_width, vrt_height


Expand Down