58 bokeh
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
# !pip install bokeh jupyter_bokeh
# !pip install bokeh jupyter_bokeh
In [3]:
Copied!
import leafmap.bokehmap as leafmap
import leafmap.bokehmap as leafmap
Create an interactive map
Specify center and zoom level
In [5]:
Copied!
m = leafmap.Map(center=[40, -100], zoom=4, height=400)
m
m = leafmap.Map(center=[40, -100], zoom=4, height=400)
m
Out[5]:
<leafmap.bokehmap.Map at 0x7fa5dac5b8c0>
Add basemaps
In [6]:
Copied!
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
Out[6]:
<leafmap.bokehmap.Map at 0x7fa5dab38620>
In [7]:
Copied!
# print(leafmap.basemaps.keys())
# print(leafmap.basemaps.keys())
Add COG
In [8]:
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
Out[8]:
<leafmap.bokehmap.Map at 0x7fa5dab39280>
Add STAC
In [9]:
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
Out[9]:
<leafmap.bokehmap.Map at 0x7fa5dab3a9f0>
Add local raster datasets
In [10]:
Copied!
url = "https://open.gishub.org/data/raster/srtm90.tif"
leafmap.download_file(url, "dem.tif")
url = "https://open.gishub.org/data/raster/srtm90.tif"
leafmap.download_file(url, "dem.tif")
dem.tif already exists. Skip downloading. Set overwrite=True to overwrite.
Out[10]:
'/home/runner/work/leafmap/leafmap/docs/notebooks/dem.tif'
In [11]:
Copied!
m = leafmap.Map()
m.add_raster("dem.tif", colormap="terrain")
m
m = leafmap.Map()
m.add_raster("dem.tif", colormap="terrain")
m
Out[11]:
<leafmap.bokehmap.Map at 0x7fa5daaf2c60>
Add points
In [12]:
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
BokehDeprecationWarning: 'circle() method with size value' was deprecated in Bokeh 3.4.0 and will be removed, use 'scatter(size=...) instead' instead.
Out[12]:
<leafmap.bokehmap.Map at 0x7fa5d1abf9b0>
Add lines
In [13]:
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
Skipping field coordinates: unsupported OGR type: 3