In [1]:
import os
import folium

print(folium.__version__)


0.8.3+52.g2758dc7.dirty

How to use ImageOverlay

It may happen that you want to draw an image on you map. Here are example on how to do that.

Using an image from disk

If you have a static image file on your disk, you can simply draw it on the map.


In [2]:
m = folium.Map([37, 0], zoom_start=1, tiles='stamentoner')
merc = os.path.join('data', 'Mercator_projection_SW.png')


if not os.path.isfile(merc):
    print(f'Could not find {merc}')
else:
    img = folium.raster_layers.ImageOverlay(
        name='Mercator projection SW',
        image=merc,
        bounds=[[-82, -180], [82, 180]],
        opacity=0.6,
        interactive=True,
        cross_origin=False,
        zindex=1,
    )

    folium.Popup('I am an image').add_to(img)

    img.add_to(m)
    folium.LayerControl().add_to(m)
    m.save(os.path.join('results', 'ImageOverlay_0.html'))

m


Out[2]: