pynhd
pynhd copied to clipboard
NLDI.get_basins() returns no features for almost all gages
What happened?
I have a list of 216 USGS gage IDs. Most of them are in Colorado. This code errors out on all of them due to "returns no features".
What did you expect to happen?
I expected it to grab the delineated watershed for each gage.
Minimal Complete Verifiable Example
gage_ids = ['07203000', '07216500', '07218000', '08247500', '08248000', '08255500', '08265000', '08266820', '08267500', '08275500', '08276300', '08277470', '08279000', '08284100', '08289000', '08291000', '08294210', '08315480', '08316000', '08377900', '08378500', '08380500', '08386505', '08400000', '08401200', '08401900', '08405150', '08405450', '08405500', '08406000', '08477110', '09386900', '09430600', '09266500', '09277500', '09279000', '09288000', '09291000', '09292000', '09292500', '09296800', '09310500', '09312600', '09337000', '09378170', '09378630', '09403600', '09404900', '09405500', '09408000', '09408400', '09409100', '09413900', '10011500', '10105900', '10109000', '10113500', '10128500', '10130500', '10131000', '10134500', '10137500', '10140100', '10146400', '10149000', '10154200', '10157500', '10164500', '10172700', '10172800', '10172952', '10173450', '10194200', '10205030', '10215900', '10234500', '06614800', '06710385', '06712000', '06715000', '06716100', '06718550', '06719505', '06730200', '06741510', '06746110', '06751150', '06751490', '07079300', '07083000', '07096250', '07103700', '07103703', '07103797', '07103800', '07105000', '07108900', '07124200', '08245000', '08246500', '09010500', '09024000', '09025000', '09025300', '09026500', '09032000', '09032100', '09034900', '09035700', '09035900', '09036000', '09037500', '09038500', '09041400', '09046490', '09047700', '09050100', '09050700', '09051050', '09059500', '09063900', '09064600', '09065100', '09065500', '09066000', '09066200', '09066300', '09066325', '09066510', '09067020', '09067200', '09073300', '09073400', '09080400', '09081600', '09109000', '09110000', '09113980', '09118450', '09124500', '09126000', '09132500', '09143500', '09146200', '09147025', '09147500', '09165000', '09166950', '09237450', '09239500', '09246200', '09253000', '09255000', '09306242', '09342500', '09353800', '09354500', '09358000', '09358550', '09359010', '09359020', '09371000', '09371520', '09372000', '401723105400000', '401733105392404', '06309200', '06622700', '06623800', '06625000', '06632400', '09188500', '09196500', '09210500', '09223000', '09229500', '10032000', '13010065', '13011900', '13016305', '13016450', '13018300', '06814000', '06853800', '06863500', '06871500', '06876700', '06878000', '06879650', '06885500', '06888500', '06889200', '06889500', '06890100', '06891500', '06892000', '06910800', '06911490', '06911900', '06912500', '06917000', '07144910', '07145700', '07147070', '07167500', '07169800', '07170700', '07172000', '07179500', '07179795', '09119000', '09304500', '06620000', '08227000', '09057500', '09105000']
basins_gdf = gpd.GeoDataFrame(columns=['gage', 'geometry'], crs="EPSG:4326")
# Loop through the gage IDs and get the basin for each
for gage_id in gage_ids:
try:
print(gage_id)
# Retrieve the watershed basin using PyNHD
basin = NLDI().get_basins(f"USGS-{gage_id}", split_catchment=True)
# Append to the main GeoDataFrame
basins_gdf = gpd.GeoDataFrame(pd.concat([basins_gdf, basin], ignore_index=True), crs=basins_gdf.crs)
print(f'got: {gage_id}')
except Exception as e:
print(f"Failed to get basin for gage {gage_id}: {e}")
MVCE confirmation
- [x] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue.
- [x] Complete example — the example is self-contained, including all data and the text of any traceback.
- [x] New issue — a search of GitHub Issues suggests this is not a duplicate.
Relevant log output
Anything else we need to know?
No response