25 map title
Creating a population heat map with a colorbar and map title
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
The notebook requires the folium plotting backend. ipyleaflet is not supported.
In [2]:
Copied!
import leafmap.foliumap as leafmap
import leafmap.foliumap as leafmap
Creates an interactive folium map.
In [3]:
Copied!
m = leafmap.Map()
m = leafmap.Map()
Specify the latitude
, longitude
, and value
columns to create the heat map.
In [4]:
Copied!
in_csv = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/world_cities.csv"
in_csv = "https://raw.githubusercontent.com/giswqs/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.
In [5]:
Copied!
m.add_heatmap(
in_csv,
latitude="latitude",
longitude='longitude',
value="pop_max",
name="Heat map",
radius=20,
)
m.add_heatmap(
in_csv,
latitude="latitude",
longitude='longitude',
value="pop_max",
name="Heat map",
radius=20,
)
Adds a colorbar to the map.
In [6]:
Copied!
colors = ['blue', 'lime', 'red']
vmin = 0
vmax = 10000
m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)
colors = ['blue', 'lime', 'red']
vmin = 0
vmax = 10000
m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)
Adds a title to the map.
In [7]:
Copied!
m.add_title("World Population Heat Map", font_size="20px", align="center")
m.add_title("World Population Heat Map", font_size="20px", align="center")
In [8]:
Copied!
m
m
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Save the map as an HTML.
In [9]:
Copied!
m.to_html("heatmap.html")
m.to_html("heatmap.html")
Last update:
2022-03-14