Lab 7#

Open In Colab

Overview#

In this lab, you will delve deeper into Leafmap, a powerful Python package for interactive geospatial mapping and analysis. You will explore how to work with various types of raster and vector data, customize basemaps and map layers, and visualize data using Cloud Optimized GeoTIFFs (COGs), PMTiles, GeoParquet, and other formats. You will also learn how to enhance your maps with advanced features like legends, colorbars, marker clusters, and split maps for comparison.

Objective#

  • Create and customize interactive maps using Leafmap.

  • Add and configure basemaps, XYZ tile layers, and WMS layers.

  • Visualize various raster formats such as GeoTIFF, Cloud Optimized GeoTIFF (COG), and multi-band imagery.

  • Explore vector data visualization, including marker clusters and choropleth maps.

  • Implement advanced mapping features like legends, colorbars, and split map comparisons.

Exercise 1: Creating an Interactive Map#

  1. Create an interactive map with search functionality that allows users to search for places and zoom to them. Disable the draw control on the map.

image

Exercise 2: Adding XYZ and WMS Tile Layers#

  1. Add a custom XYZ tile layer (USGS Topographic basemap) using the following URL:

    • URL: https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}

  2. Add two WMS layers to visualize NAIP imagery and NDVI using a USGS WMS service.

    • URL: https://imagery.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?

    • Layer names: USGSNAIPImagery:FalseColorComposite, USGSNAIPImagery:NDVI_Color

image

image

Exercise 3: Adding Map Legends#

  1. Add the ESA World Cover WMS tile layer to the map.

    • URL: https://services.terrascope.be/wms/v2?

    • Layer name: WORLDCOVER_2021_MAP

  2. Add a legend to the map using the leafmap built-in ESA_WorldCover legend.

image

Exercise 4: Creating Marker Clusters#

  1. Create a marker cluster visualization from a GeoJSON file of building centroids:

    • URL: opengeos/datasets

    • Hint: Read the GeoJSON file using GeoPandas and add “latitude” and “longitude” columns to the GeoDataFrame.

  2. Create circle markers for each building centroid using the Map.add_circle_markers_from_xy() method with the following styling:

    • Radius: 5

    • Outline color: “red”

    • Fill color: “yellow”

    • Fill opacity: 0.8

image

image

Exercise 5: Visualizing Vector Data#

  1. Visualize the building polygons GeoJSON file and style it with:

  2. Visualize the road polylines GeoJSON file and style it with:

  3. Create a choropleth map of county areas in the US:

image

image

image

Exercise 6: Visualizing GeoParquet Data#

  1. Visualize GeoParquet data of US states:

image

Exercise 7: Visualizing PMTiles#

  1. Visualize the Overture Maps building dataset using PMTiles:

image

Exercise 8: Visualizing Cloud Optimized GeoTIFFs (COGs)#

  1. Visualize Digital Elevation Model (DEM) data using the following COG file:

image

Exercise 9: Visualizing Local Raster Data#

  1. Visualize the following raster datasets using the Map.add_raster() method:

image

Exercise 10: Creating a Split Map#

  1. Create a split map to compare imagery of Libya before and after the 2023 flood event:

image