Repository navigation
Conversation
When lat_bounds went beyond the Web Mercator limit (+-85.0511), the input rows were placed between the clipped bounds, so data from the full range was squeezed into it. For a global (-90, 90) image the rows were shifted towards the equator by up to ~5 degrees. Lay the input rows out over the original bounds and only clip the output, as the docstring describes.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
mercator_transformdocstring (andImageOverlay(mercator_project=True)) says the image is clipped beyond latitude ±85.05. In practice, whenlat_boundsgoes past that limit, the input rows are laid out between the clipped bounds. The data from the full range is squeezed into ±85.05 instead of being cropped. For a global(-90, 90)grid, every row away from the equator is drawn too far toward it, by up to about 5 degrees. For example, the bottom output row (centred at about -84.96°) gets the -89.5° row's value. The global "Good" example indocs/advanced_guide/geodedetic_image_overlay.mduses these bounds.Changes
Compute the input row latitudes from the original
lat_bounds, and keep the clipped bounds only for the output grid. Bounds inside ±85.05 give the same result as before.The new test checks that each output row of a latitude-valued global image holds its own centre latitude (within 0.05°, well inside a 1° input pixel). The expected PNG in
test_image_overlaychanges, because that test uses bounds[0, 90]. Its south row is now interpolated from rows centred at 22.5° and 67.5° rather than 21.3° and 63.8°.Validation
folium/utilities.pyreverted), the new test fails ([0]: -89.5 (ACTUAL), -84.964 (DESIRED), max abs difference 4.90) andtest_image_overlayfails on the old URL. With the fix both pass.python -m pytest tests --ignore=tests/selenium --ignore=tests/snapshots: 396 passed, 3 failed. The 3 failures are intests/test_repr.py(cannot import name 'webdriver' from 'selenium', since selenium isn't installed) and fail the same way onmain.ruff check folium tests(0.16.10),black --check(26.10.0),codespellon the changed files, andmypy foliumpass.