02 using basemaps
In [ ]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [ ]:
Copied!
import leafmap
import leafmap
Create an interactive map.
In [ ]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Specify a Google basemap to use, can be one of ["ROADMAP", "TERRAIN", "SATELLITE", "HYBRID"].
In [ ]:
Copied!
m = leafmap.Map(google_map="HYBRID")
m
m = leafmap.Map(google_map="HYBRID")
m
In [ ]:
Copied!
m = leafmap.Map(google_map="TERRAIN")
m
m = leafmap.Map(google_map="TERRAIN")
m
Add a basemap using the add_basemap()
function.
In [ ]:
Copied!
m = leafmap.Map()
m.add_basemap("HYBRID")
m.add_basemap("Esri.NatGeoWorldMap")
m
m = leafmap.Map()
m.add_basemap("HYBRID")
m.add_basemap("Esri.NatGeoWorldMap")
m
Add an XYZ tile layer.
In [ ]:
Copied!
m = leafmap.Map()
m.add_tile_layer(
url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
name="Google Satellite",
attribution="Google",
)
m
m = leafmap.Map()
m.add_tile_layer(
url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
name="Google Satellite",
attribution="Google",
)
m
Add a WMS tile layer.
In [ ]:
Copied!
m = leafmap.Map()
naip_url = "https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?"
m.add_wms_layer(
url=naip_url, layers="0", name="NAIP Imagery", format="image/png", shown=True
)
m
m = leafmap.Map()
naip_url = "https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?"
m.add_wms_layer(
url=naip_url, layers="0", name="NAIP Imagery", format="image/png", shown=True
)
m
Add a legend to the map.
In [ ]:
Copied!
m = leafmap.Map(google_map="HYBRID")
url1 = "https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?"
m.add_wms_layer(
url1, layers="1", format="image/png", transparent=True, name="NWI Wetlands Vector"
)
url2 = "https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?"
m.add_wms_layer(
url2, layers="0", format="image/png", transparent=True, name="NWI Wetlands Raster"
)
m.add_legend(builtin_legend="NWI")
m
m = leafmap.Map(google_map="HYBRID")
url1 = "https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?"
m.add_wms_layer(
url1, layers="1", format="image/png", transparent=True, name="NWI Wetlands Vector"
)
url2 = "https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?"
m.add_wms_layer(
url2, layers="0", format="image/png", transparent=True, name="NWI Wetlands Raster"
)
m.add_legend(builtin_legend="NWI")
m