python-visualization / python-visualization/folium

ImageOverlay behaviour with WG84 rasters

Open
#2,054 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.4k
Forks
2.3k
Avg merge
17h 22m
Merged PRs (30d)
11

Description

I have a non-expected result when using this code (the raster used is attached to this message):

raster_path = '2019-06-15.tiff'
with rasterio.open(raster_path) as src:
    raster_data = src.read(1)
    bounds = src.bounds
    
m = folium.Map(location=[(bounds.top + bounds.bottom) / 2, (bounds.left + bounds.right) / 2], zoom_start=10)

# Create an ImageOverlay
img_overlay = ImageOverlay(
    image=raster_data,
    bounds=[[bounds.bottom, bounds.left], [bounds.top, bounds.right]],
    opacity=0.6,
    interactive=False,
    cross_origin=True,
    zindex=1,
    mercator_project=True
)

# Add the overlay to the map
img_overlay.add_to(m)

m.save('map.html')

Indeed, my result html map presents shapes that are not consistent with the same map I could have just by using QGIS.

For instance the result of this code gives this in a specific region:
image

while using QGIS in an EPSG:3857 projection system gives this:
image

My raster has natively an EPSG:4326 projection system. I suspect the issue comes from how ImageOverlay changes the projection system.

Can anyone reproduce this and explain how I could obtain the same result as in QGIS which is the correct reference for me?

Thanks,
Vivien

2019-06-15.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied TIFF example with rasterio and folium.ImageOverlay, then compare its EPSG:4326 handling with the EPSG:3857 QGIS result. Read the ImageOverlay projection and bounds behavior alongside Leaflet's image-overlay expectations; done means the discrepancy is explained and the issue's expected rendering or limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
data-visualization, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.