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/opengeos/leafmap/master/examples/data/world_cities.csv"
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.
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]:
Save the map as an HTML.
InĀ [9]:
Copied!
m.to_html("heatmap.html")
m.to_html("heatmap.html")