58 bokeh
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [ ]:
Copied!
# !pip install bokeh jupyter_bokeh
# !pip install bokeh jupyter_bokeh
In [ ]:
Copied!
import leafmap.bokehmap as leafmap
import leafmap.bokehmap as leafmap
Create an interactive map
In [ ]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Specify center and zoom level
In [ ]:
Copied!
m = leafmap.Map(center=[40, -100], zoom=4, height=400)
m
m = leafmap.Map(center=[40, -100], zoom=4, height=400)
m
Add basemaps
In [ ]:
Copied!
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
In [ ]:
Copied!
# print(leafmap.basemaps.keys())
# print(leafmap.basemaps.keys())
Add COG
In [ ]:
Copied!
m = leafmap.Map()
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif"
m.add_cog_layer(url)
m
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
In [ ]:
Copied!
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
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
In [ ]:
Copied!
url = "https://opengeos.org/data/raster/srtm90.tif"
leafmap.download_file(url, "dem.tif")
url = "https://opengeos.org/data/raster/srtm90.tif"
leafmap.download_file(url, "dem.tif")
In [ ]:
Copied!
m = leafmap.Map()
m.add_raster("dem.tif", colormap="terrain")
m
m = leafmap.Map()
m.add_raster("dem.tif", colormap="terrain")
m
Add points
In [ ]:
Copied!
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
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
In [ ]:
Copied!
m = leafmap.Map()
m.add_basemap("CartoDB.DarkMatter")
url = "https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson"
m.add_vector(url, line_color="color", line_width=2)
m
m = leafmap.Map()
m.add_basemap("CartoDB.DarkMatter")
url = "https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson"
m.add_vector(url, line_color="color", line_width=2)
m
Add polygons
In [ ]:
Copied!
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
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