First notebook in the Thornforest hydrology series. It builds the spatial foundation (the three HUC-8 watershed boundaries) that the other notebooks rely on, and maps it.
Our study area is three HUC-8 subbasins in South Texas: - South Laguna Madre (12110208) - Los Olmos (13090001) - Lower Rio Grande (13090002)
New to Python notebooks? Run each cell in order with Shift + Enter.
Step 1 — Imports and setup
All imports are at the top. init_session() (from our shared _helpers module) loads the optional USGS API key, configures the on-disk request cache, and returns the paths we use.
Show code
from pygeohydro import WBDimport geoviews as gvimport geoviews.tile_sources as gvtsfrom _helpers import init_session, save_dataframe, save_workbook, show, categorical_colorsgv.extension("bokeh")S = init_session()
ⓘ
USGS API key loaded.
Step 2 — Name our three watersheds
A dictionary maps each HUC-8 code to a friendly name. Colors come from a colorcet categorical palette (via categorical_colors) so the figure data colors are perceptually distinct and consistent across the project.
WBD("huc8").byids(...) fetches the three boundaries from the USGS Watershed Boundary Dataset. The request is cached on disk; the result is also saved to data/hydrography/.
/Users/aaufdenkampe/Documents/git_Limno/Thornforest/notebooks/_helpers/excel.py:71: UserWarning: Cell contents too long (107804), truncated to 32767 characters
df.to_excel(writer, sheet_name=sheet_name, index=False)
/Users/aaufdenkampe/Documents/git_Limno/Thornforest/notebooks/_helpers/excel.py:71: UserWarning: Cell contents too long (75339), truncated to 32767 characters
df.to_excel(writer, sheet_name=sheet_name, index=False)
/Users/aaufdenkampe/Documents/git_Limno/Thornforest/notebooks/_helpers/excel.py:71: UserWarning: Cell contents too long (182871), truncated to 32767 characters
df.to_excel(writer, sheet_name=sheet_name, index=False)
What’s next
The boundaries are saved to data/hydrography/. Notebook 3_usgs_waterdata reads them to discover the USGS monitoring stations inside the watersheds and the parameters they measure.