pynhd.pynhd#
Access NLDI and WaterData databases.
Module Contents#
- class pynhd.pynhd.HP3D(layer, outfields='*', crs=4326)#
Access USGS 3D Hydrography Program (3DHP) service.
Notes
For more info visit: https://hydro.nationalmap.gov/arcgis/rest/services/3DHP_all/MapServer
- Parameters:
layer (
str, optional) – A valid service layer. Layer names with_hrare high resolution and_mrare medium resolution. Also, layer names with_nonconusare for non-conus areas, i.e., Alaska, Hawaii, Puerto Rico, the Virgin Islands , and the Pacific Islands. Valid layers are:hydrolocation_waterbodyfor Sink, Spring, Waterbody Outlethydrolocation_flowlinefor Headwater, Terminus, Divergence, Confluence, Catchment Outlethydrolocation_reachfor Reach Code, External Connectionflowlinefor river flowlineswaterbodyfor waterbodiesdrainage_areafor drainage areascatchmentfor catchments
outfields (
strorlist, optional) – Target field name(s), default to “*” i.e., all the fields.crs (
str,int, orpyproj.CRS, optional) – Target spatial reference, default toEPSG:4326.
- bygeom(geom, geo_crs=4326, sql_clause='', distance=None, return_m=False, return_geom=True)#
Get features within a geometry that can be combined with a SQL where clause.
- byids(field, fids, return_m=False, return_geom=True)#
Get features by object IDs.
- bysql(sql_clause, return_m=False, return_geom=True)#
Get features using a valid SQL 92 WHERE clause.
- class pynhd.pynhd.NHD(layer, outfields='*', crs=4326)#
Access National Hydrography Dataset (NHD), both meduim and high resolution.
Notes
For more info visit: https://hydro.nationalmap.gov/arcgis/rest/services/nhd/MapServer
- Parameters:
layer (
str, optional) – A valid service layer. Layer names with_hrare high resolution and_mrare medium resolution. Also, layer names with_nonconusare for non-conus areas, i.e., Alaska, Hawaii, Puerto Rico, the Virgin Islands , and the Pacific Islands. Valid layers are:pointpoint_eventline_hrflow_directionflowline_mrflowline_hr_nonconusflowline_hrarea_mrarea_hr_nonconusarea_hrwaterbody_mrwaterbody_hr_nonconuswaterbody_hr
outfields (
strorlist, optional) – Target field name(s), default to “*” i.e., all the fields.crs (
str,int, orpyproj.CRS, optional) – Target spatial reference, default toEPSG:4326.
- bygeom(geom, geo_crs=4326, sql_clause='', distance=None, return_m=False, return_geom=True)#
Get features within a geometry that can be combined with a SQL where clause.
- byids(field, fids, return_m=False, return_geom=True)#
Get features by object IDs.
- bysql(sql_clause, return_m=False, return_geom=True)#
Get features using a valid SQL 92 WHERE clause.
- class pynhd.pynhd.NHDPlusHR(layer, outfields='*', crs=4326)#
Access National Hydrography Dataset (NHD) Plus high resolution.
Notes
For more info visit: https://hydro.nationalmap.gov/arcgis/rest/services/NHDPlus_HR/MapServer
- Parameters:
layer (
str, optional) – A valid service layer. Valid layers are:gagefor NHDPlusGage layersinkfor NHDPlusSink layerpointfor NHDPoint layerflowlinefor NetworkNHDFlowline layernon_network_flowlinefor NonNetworkNHDFlowline layerflow_directionfor FlowDirection layerwallfor NHDPlusWall layerlinefor NHDLine layerareafor NHDArea layerwaterbodyfor NHDWaterbody layercatchmentfor NHDPlusCatchment layerboundary_unitfor NHDPlusBoundaryUnit layerhuc12for WBDHU12 layer
outfields (
strorlist, optional) – Target field name(s), default to “*” i.e., all the fields.crs (
str,int, orpyproj.CRS, optional) – Target spatial reference, default toEPSG:4326.
- bygeom(geom, geo_crs=4326, sql_clause='', distance=None, return_m=False, return_geom=True)#
Get features within a geometry that can be combined with a SQL where clause.
- byids(field, fids, return_m=False, return_geom=True)#
Get features by object IDs.
- bysql(sql_clause, return_m=False, return_geom=True)#
Get features using a valid SQL 92 WHERE clause.
- class pynhd.pynhd.WaterData(layer, crs=4326)#
Access WaterData service.
- Parameters:
layer (
str) – A valid layer from the WaterData service. Valid layers are:catchmentspgagesiigagesii_basinsnhdareanhdflowline_networknhdflowline_nonnetworknhdwaterbodywbd02wbd04wbd06wbd08wbd10wbd12
Note that all
wbd*layers provide access to the October 2020 snapshot of the Watershed Boundary Dataset (WBD). If you need the latest version, please use theWBDclass from the PyGeoHydro package.crs (
str,int, orpyproj.CRS, optional) – The target spatial reference system, defaults toepsg:4326.
- bybox(bbox, box_crs=4326, sort_attr=None)#
Get features within a bounding box.
- Parameters:
bbox (
tupleoffloats) – A bounding box in the form of (minx, miny, maxx, maxy).box_crs (
str,int, orpyproj.CRS, optional) – The spatial reference system of the bounding box, defaults toepsg:4326.sort_attr (
str, optional) – The column name in the database to sort request by, defaults to the first attribute in the schema that containsidin its name.
- Returns:
geopandas.GeoDataFrame– The requested features in a GeoDataFrames.- Return type:
- bydistance(coords, distance, loc_crs=4326, sort_attr=None)#
Get features within a radius (in meters) of a point.
- Parameters:
coords (
tupleoffloat) – The x, y coordinates of the point.distance (
int) – The radius (in meters) to search within.loc_crs (
str,int, orpyproj.CRS, optional) – The CRS of the input coordinates, default toepsg:4326.sort_attr (
str, optional) – The column name in the database to sort request by, defaults to the first attribute in the schema that containsidin its name.
- Returns:
geopandas.GeoDataFrame– Requested features as a GeoDataFrame.- Return type:
- byfilter(cql_filter, method='GET', sort_attr=None)#
Get features based on a CQL filter.
- Parameters:
cql_filter (
str) – The CQL filter to use for requesting the data.method (
str, optional) – The HTTP method to use for requesting the data, defaults to GET. Allowed methods are GET and POST.sort_attr (
str, optional) – The column name in the database to sort request by, defaults to the first attribute in the schema that containsidin its name.
- Returns:
geopandas.GeoDataFrame– The requested features as a GeoDataFrames.- Return type:
- bygeom(geometry, geo_crs=4326, xy=True, predicate='intersects', sort_attr=None)#
Get features within a geometry.
- Parameters:
geometry (
shapely.Polygonorshapely.MultiPolygon) – The input (multi)polygon to request the data.geo_crs (
str,int, orpyproj.CRS, optional) – The CRS of the input geometry, default to epsg:4326.xy (
bool, optional) – Whether axis order of the input geometry is xy or yx.predicate (
str, optional) – The geometric prediacte to use for requesting the data, defaults to INTERSECTS. Valid predicates are:equalsdisjointintersectstouchescrosseswithincontainsoverlapsrelatebeyond
sort_attr (
str, optional) – The column name in the database to sort request by, defaults to the first attribute in the schema that containsidin its name.
- Returns:
geopandas.GeoDataFrame– The requested features in the given geometry.- Return type:
- byid(featurename, featureids)#
Get features based on IDs.