Closed Ceyxleo closed 2 years ago
Thanks for reporting this. It seems that the two stations are close and their COMID belong to a non-network flowline:
from pynhd import NLDI, NHD
from pygeohydro import NWIS
import geopandas as gpd
nwis = NWIS()
info = nwis.get_info({"site": "04253294,04253296"})
coords = list(zip(info.dec_long_va, info.dec_lat_va))
nldi = NLDI()
comids = nldi.comid_byloc(coords)
ids = list(set(comids.comid))
nhd = NHD("flowline_mr")
flw = nhd.byids("COMID", ids)
bbox = gpd.GeoSeries(info.geometry.tolist() + flw.geometry.tolist()).unary_union.bounds
nhd_wb = NHD("waterbody_hr")
wb = nhd_wb.bygeom(bbox)
ax = flw.plot(color="r", label="Flowline", figsize=(10, 10))
wb.plot(ax=ax, color="b", alpha=0.2, label="Water Bodies")
info.plot(ax=ax, label="Stations")
ax.set_title(flw.GNIS_NAME.values[0])
ax.legend()
The non-flowline COMIDs are not included in NLDI, that's why it returns an empty geometry.
Thanks man!
Best, Lingbo
Taher Chegini @.***> 于2022年1月26日周三 23:13写道:
Thanks for reporting this. It seems that the two stations are close and their COMID belong to a non-network flowline:
from pynhd import NLDI, NHDfrom pygeohydro import NWISimport geopandas as gpd nwis = NWIS()info = nwis.get_info({"site": "04253294,04253296"})coords = list(zip(info.dec_long_va, info.dec_lat_va)) nldi = NLDI()comids = nldi.comid_byloc(coords)ids = list(set(comids.comid)) nhd = NHD("flowline_mr")flw = nhd.byids("COMID", ids) bbox = gpd.GeoSeries(info.geometry.tolist() + flw.geometry.tolist()).unary_union.boundsnhd_wb = NHD("waterbody_hr")wb = nhd_wb.bygeom(bbox) ax = flw.plot(color="r", label="Flowline", figsize=(10, 10))wb.plot(ax=ax, color="b", alpha=0.2, label="Water Bodies")info.plot(ax=ax, label="Stations")ax.set_title(flw.GNIS_NAME.values[0])ax.legend()
[image: image] https://user-images.githubusercontent.com/13016644/151295808-afffde4a-eafd-4f41-a1f1-0b1f1c4ee544.png
The non-flowline COMIDs are not included in NLDI, that's why it returns an empty geometry.
— Reply to this email directly, view it on GitHub https://github.com/cheginit/pynhd/issues/48#issuecomment-1022855370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWTLJG3DC52VSMFLTTIF5CTUYDH6TANCNFSM5M3777DA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
What happened: Find None values in the return dataframe of using nldi.get_basins() function
What you expected to happen: If nothing for this USGS station, just return the str of the usgs id
Minimal Complete Verifiable Example:
Anything else we need to know?: To be more specific, the USGS_id which return none are ''04253294" and "04253296"
Environment:
Output of pynhd.show_versions()
``` INSTALLED VERSIONS ------------------ commit: None python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:36:06) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 85 Stepping 7, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: English_United States.1252 aiohttp-client-cache>=0.5.1: None aiohttp>=3.8.1: None aiosqlite: 0.17.0 async-retriever: 0.3.1 async-retriever>=0.3.1: None cytoolz: 0.11.2 dask: 2021.12.0 defusedxml: 0.7.1 geopandas>=0.7: None netCDF4: 1.5.8 networkx: 2.6.3 numpy>=1.17: None owslib: 0.25.0 pandas>=1.0: None pip: 21.3.1 py3dep: None pyarrow: 6.0.0 pydantic: 1.9.0 pydaymet: None pygeohydro: None pygeoogc: 0.12.2 pygeoogc>=0.12: None pygeos: 0.12.0 pygeoutils: 0.12.2 pygeoutils>=0.12: None pynhd: 0.3.1 pyproj>=2.2: None pytest: None rasterio>=1.2: None requests: 2.26.0 requests-cache>=0.8: None rioxarray>=0.8: None scipy: 1.7.3 setuptools: 59.8.0 shapely>=1.6: None ujson: 5.1.0 urllib3: 1.26.7 ward: None xarray>=0.18: None yaml: 6.0 ```