#!/usr/bin/env python # coding: utf-8 # [![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/99_wetlands.ipynb) # [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/99_wetlands.ipynb) # [![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD) # # **Retrieving wetland boundaries from the National Wetlands Inventory (NWI)** # # The [National Wetlands Inventory (NWI)](https://www.fws.gov/program/national-wetlands-inventory/wetlands-data) is a comprehensive geospatial inventory of U.S. wetlands. It is a publicly available resource that provides detailed information on the abundance, characteristics, and distribution of wetlands in the United States. The NWI dataset is maintained by the U.S. Fish and Wildlife Service (USFWS) and is used by a wide range of stakeholders, including federal, state, and local agencies, researchers, and conservation organizations. # # The notebook demonstrates how to retrieve wetland boundaries from the NWI using the `leafmap` Python package. The NWI dataset is available as a web service, which allows users to access the data programmatically. The `leafmap` package provides a simple interface for querying the NWI web service and visualizing the wetland boundaries on an interactive map. # # Uncomment the following line to install [leafmap](https://leafmap.org) if needed. # In[ ]: # %pip install -U leafmap # In[ ]: import leafmap # In[ ]: m = leafmap.Map(center=[47.223940, -99.885386], zoom=14) m.add_basemap("HYBRID") m # ## Using point geometry # In[ ]: point_geometry = {"x": -99.907986, "y": 47.216359} # In[ ]: gdf = leafmap.get_nwi(point_geometry) # In[ ]: m = leafmap.Map(center=[47.223940, -99.885386], zoom=14) m.add_basemap("HYBRID") m.add_nwi(gdf, add_legend=True) m # ## Using bounding box # In[ ]: bbox_geometry = {"xmin": -99.9023, "ymin": 47.211, "xmax": -99.8556, "ymax": 47.2325} # In[ ]: gdf = leafmap.get_nwi(bbox_geometry) # In[ ]: m = leafmap.Map() m.add_basemap("HYBRID") m.add_nwi(gdf, layer_name="Wetlands", zoom_to_layer=True) m # ## Using GeoDataFrame # In[ ]: bbox = [-99.8653, 47.3952, -99.7498, 47.4441] bbox_geometry = leafmap.bbox_to_gdf(bbox) bbox_geometry # In[ ]: gdf = leafmap.get_nwi(bbox_geometry) # In[ ]: m = leafmap.Map() m.add_basemap("HYBRID") m.add_nwi(gdf, layer_name="Wetlands", zoom_to_layer=True) m # ## Using HUC8 watershed boundary # In[ ]: huc8 = "11120104" # In[ ]: gdf = leafmap.get_nwi_by_huc8(huc8, quiet=False) # In[ ]: m = leafmap.Map() m.add_basemap("HYBRID") m.add_nwi(gdf, layer_name="Wetlands", zoom_to_layer=True) m