Skip to content

28 publish map

image image image

Uncomment the following line to install leafmap if needed.

1
# !pip install leafmap

To follow this tutorial, you will need to sign up for an account with https://datapane.com, then install and authenticate the datapane Python package. More information can be found here.

  • pip install datapane
  • datapane login
  • datapane ping
1
import leafmap.foliumap as leafmap

Create an elevation map of North America.

1
2
3
4
5
6
7
m = leafmap.Map()
m.add_basemap("USGS 3DEP Elevation")
colors = ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"]
vmin = 0
vmax = 4000
m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)
m

Publish the map to datapane.com

1
m.publish(name="Elevation Map of North America")

Create a land use and land cover map.

1
2
3
4
m = leafmap.Map()
m.add_basemap("NLCD 2016 CONUS Land Cover")
m.add_legend(builtin_legend="NLCD")
m

Publish the map to datapane.com.

1
m.publish(name="National Land Cover Database (NLCD) 2016")

Create a world population heat map.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
m = leafmap.Map()
in_csv = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv"
m.add_heatmap(
    in_csv,
    latitude="latitude",
    longitude="longitude",
    value="pop_max",
    name="Heat map",
    radius=20,
)
1
2
3
4
5
colors = ["blue", "lime", "red"]
vmin = 0
vmax = 10000
m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)
m

Publish the map to datapane.com.

1
m.publish(name="World Population Heat Map")