Skip to content

33 image overlay

image image image

Uncomment the following line to install leafmap if needed.

1
# !pip install leafmap
1
2
import os
from leafmap import leafmap

Using local files

Download the sample png from https://i.imgur.com/06Q1fSz.png to your Downloads folder.

1
2
3
4
filepath = "weather.png"
url = "https://opengeos.org/data/images/weather.png"
if not os.path.exists(filepath):
    leafmap.download_file(url, filepath)
1
2
3
4
5
6
m = leafmap.Map(center=(25, -115), zoom=4)

image = leafmap.ImageOverlay(url=filepath, bounds=((13, -130), (32, -100)))

m.add_layer(image)
m

Using remote files

1
2
3
4
5
6
m = leafmap.Map(center=(25, -115), zoom=4)

image = leafmap.ImageOverlay(url=url, bounds=((13, -130), (32, -100)))

m.add_layer(image)
m

Update image url

1
# image.url = "https://i.imgur.com/J9qCf4E.png"