# !pip install leafmap geopandas pycrs osmnx import os import leafmap m = leafmap.Map(center=(40, -100), zoom=4) m m = leafmap.Map(height="400px", width="800px") m m = leafmap.Map( draw_control=False, measure_control=False, fullscreen_control=False, attribution_control=True, ) m m = leafmap.Map() m.add_basemap("OpenTopoMap") 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 m = leafmap.Map(center=[40, -100], zoom=4) naip_url = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?" m.add_wms_layer( url=naip_url, layers="NLCD_2019_Land_Cover_L48", name="NLCD 2019", attribution="MRLC", format="image/png", shown=True, ) m.add_legend(title="NLCD Land Cover Type", builtin_legend="NLCD") m m = leafmap.Map() url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif" m.add_cog_layer(url, name="Fire (pre-event)") 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 m = leafmap.Map() url = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/wms?" m.add_wms_layer( url, layers="NLCD_2016_Land_Cover_L48", name="NLCD 2016 CONUS Land Cover", format="image/png", transparent=True, ) m.add_legend(builtin_legend="NLCD") m 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 m = leafmap.Map(center=[0, 0], zoom=2) in_geojson = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson" m.add_geojson(in_geojson, layer_name="Cable lines") m # Add a GeoJSON with random filled color to the map. m = leafmap.Map(center=[0, 0], zoom=2) url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson" style = {"fillOpacity": 0.5} m.add_geojson( url, layer_name="Countries", style=style, fill_colors=["red", "yellow", "green", "orange"], ) m # Use custom style and hover_style functions. m = leafmap.Map(center=[0, 0], zoom=2) url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson" style = { "stroke": True, "color": "#0000ff", "weight": 2, "opacity": 1, "fill": True, "fillColor": "#0000ff", "fillOpacity": 0.1, } hover_style = {"fillOpacity": 0.7} m.add_geojson(url, layer_name="Countries", style=style, hover_style=hover_style) m m = leafmap.Map(center=[0, 0], zoom=2) in_shp = "https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip" m.add_shp(in_shp, layer_name="Countries") m try: import geopandas except ImportError: print("Installing geopandas ...") subprocess.check_call(["python", "-m", "pip", "install", "geopandas"]) m = leafmap.Map() in_kml = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.kml" m.add_kml(in_kml, layer_name="US States KML") m import geopandas as gpd m = leafmap.Map() gdf = gpd.read_file( "https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson" ) m.add_gdf(gdf, layer_name="Cable lines") m 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, ) colors = ["blue", "lime", "red"] vmin = 0 vmax = 10000 m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax) m.add_title("World Population Heat Map", font_size="20px", align="center") m m = leafmap.Map() m.add_basemap("Esri.NatGeoWorldMap") m m.to_html("mymap.html") os.environ["PLANET_API_KEY"] = "your-api-key" m = leafmap.Map() m.add_planet_by_month(year=2020, month=8) m.add_planet_by_quarter(year=2019, quarter=2) m