Creating a population heat map with a colorbar and map title
Uncomment the following line to install leafmap if needed.
# !pip install leafmap
The notebook requires the folium plotting backend. ipyleaflet is not supported.
import leafmap.foliumap as leafmap
Creates an interactive folium map.
m = leafmap.Map()
Specify the latitude
, longitude
, and value
columns to create the heat map.
in_csv = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv"
Specify the file path to the CSV. It can either be a file locally or on the Internet.
m.add_heatmap(
in_csv,
latitude="latitude",
longitude="longitude",
value="pop_max",
name="Heat map",
radius=20,
)
Adds a colorbar to the map.
colors = ["blue", "lime", "red"]
vmin = 0
vmax = 10000
m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)
Adds a title to the map.
m.add_title("World Population Heat Map", font_size="20px", align="center")
m
Save the map as an HTML.
m.to_html("heatmap.html")