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_hr
are high resolution and_mr
are medium resolution. Also, layer names with_nonconus
are for non-conus areas, i.e., Alaska, Hawaii, Puerto Rico, the Virgin Islands , and the Pacific Islands. Valid layers are:hydrolocation_waterbody
for Sink, Spring, Waterbody Outlethydrolocation_flowline
for Headwater, Terminus, Divergence, Confluence, Catchment Outlethydrolocation_reach
for Reach Code, External Connectionflowline
for river flowlineswaterbody
for waterbodiesdrainage_area
for drainage areascatchment
for catchments
outfields (
str
orlist
, 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_hr
are high resolution and_mr
are medium resolution. Also, layer names with_nonconus
are for non-conus areas, i.e., Alaska, Hawaii, Puerto Rico, the Virgin Islands , and the Pacific Islands. Valid layers are:point
point_event
line_hr
flow_direction
flowline_mr
flowline_hr_nonconus
flowline_hr
area_mr
area_hr_nonconus
area_hr
waterbody_mr
waterbody_hr_nonconus
waterbody_hr
outfields (
str
orlist
, 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:gage
for NHDPlusGage layersink
for NHDPlusSink layerpoint
for NHDPoint layerflowline
for NetworkNHDFlowline layernon_network_flowline
for NonNetworkNHDFlowline layerflow_direction
for FlowDirection layerwall
for NHDPlusWall layerline
for NHDLine layerarea
for NHDArea layerwaterbody
for NHDWaterbody layercatchment
for NHDPlusCatchment layerboundary_unit
for NHDPlusBoundaryUnit layerhuc12
for WBDHU12 layer
outfields (
str
orlist
, 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:catchmentsp
gagesii
gagesii_basins
nhdarea
nhdflowline_network
nhdflowline_nonnetwork
nhdwaterbody
wbd02
wbd04
wbd06
wbd08
wbd10
wbd12
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 theWBD
class 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 (
tuple
offloats
) – 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 containsid
in 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 (
tuple
offloat
) – 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 containsid
in 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 containsid
in 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.Polygon
orshapely.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:equals
disjoint
intersects
touches
crosses
within
contains
overlaps
relate
beyond
sort_attr (
str
, optional) – The column name in the database to sort request by, defaults to the first attribute in the schema that containsid
in its name.
- Returns:
geopandas.GeoDataFrame
– The requested features in the given geometry.- Return type:
- byid(featurename, featureids)#
Get features based on IDs.