Skip to content

24 heatmap

image image image

Creating heat maps from csv

Uncomment the following line to install leafmap if needed.

1
# !pip install leafmap

Specify the file path to the CSV. It can either be a file locally or on the Internet.

1
filepath = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv"

Use the ipyleaflet plotting backend.

1
import leafmap.leafmap as leafmap

Specify the latitude, longitude, and value columns to create the heat map.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
m = leafmap.Map()
m.add_heatmap(
    filepath,
    latitude="latitude",
    longitude="longitude",
    value="pop_max",
    name="Heat map",
    radius=20,
)
m

Use the folium plotting backend.

1
import leafmap.foliumap as leafmap

Specify the latitude, longitude, and value columns to create the heat map.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
m = leafmap.Map()
m.add_heatmap(
    filepath,
    latitude="latitude",
    longitude="longitude",
    value="pop_max",
    name="Heat map",
    radius=20,
)
m