Skip to content

58 bokeh

image image image

Uncomment the following line to install leafmap if needed.

1
# !pip install leafmap
1
# !pip install bokeh jupyter_bokeh
1
import leafmap.bokehmap as leafmap

Create an interactive map

1
2
m = leafmap.Map()
m

Specify center and zoom level

1
2
m = leafmap.Map(center=[40, -100], zoom=4, height=400)
m

Add basemaps

1
2
3
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
1
# print(leafmap.basemaps.keys())

Add COG

1
2
3
4
m = leafmap.Map()
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif"
m.add_cog_layer(url)
m

Add STAC

1
2
3
4
m = leafmap.Map()
url = "https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json"
m.add_stac_layer(url, bands=["B3", "B2", "B1"], name="False color")
m

Add local raster datasets

1
2
url = "https://opengeos.org/data/raster/srtm90.tif"
leafmap.download_file(url, "dem.tif")
1
2
3
m = leafmap.Map()
m.add_raster("dem.tif", colormap="terrain")
m

Add points

1
2
3
4
m = leafmap.Map()
url = "https://github.com/opengeos/leafmap/blob/master/examples/data/us_cities.geojson"
m.add_geojson(url, size=10, color="blue", alpha=0.7)
m

Add lines

1
2
3
4
5
m = leafmap.Map()
m.add_basemap("CartoDB.DarkMatter")
url = "https://github.com/opengeos/datasets/releases/download/vector/cables.geojson"
m.add_vector(url, line_color="color", line_width=2)
m

Add polygons

1
2
3
4
m = leafmap.Map()
url = "https://github.com/opengeos/leafmap/blob/master/examples/data/countries.geojson"
m.add_vector(url, fill_alpha=0.5, fill_color="lightblue")
m