pynhd.core
Contents
pynhd.core
#
Base classes for PyNHD functions.
Module Contents#
- class pynhd.core.AGRBase(base_url, layer=None, outfields='*', crs=DEF_CRS, outformat='json')#
Base class for getting geospatial data from a ArcGISRESTful service.
- Parameters
base_url (
str
, optional) – The ArcGIS RESTful service url. The URL must either include a layer number after the last/
in the url or the target layer must be passed as an argument.layer (
str
, optional) – A valid service layer. To see a list of available layers instantiate the class without passing any argument.outfields (
str
orlist
, optional) – Target field name(s), default to “*” i.e., all the fields.crs (
str
, optional) – Target spatial reference, default to EPSG:4326outformat (
str
, optional) – One of the output formats offered by the selected layer. If not correct a list of available formats is shown, defaults tojson
.
- bygeom(geom, geo_crs=DEF_CRS, sql_clause='', distance=None, return_m=False, return_geom=True)#
Get feature within a geometry that can be combined with a SQL where clause.
- Parameters
geom (
Polygon
ortuple
) – A geometry (Polygon) or bounding box (tuple of length 4).geo_crs (
str
) – The spatial reference of the input geometry.sql_clause (
str
, optional) – A valid SQL 92 WHERE clause, defaults to an empty string.distance (
int
, optional) – The buffer distance for the input geometries in meters, default to None.return_m (
bool
, optional) – Whether to activate the Return M (measure) in the request, defaults to False.return_geom (
bool
, optional) – Whether to return the geometry of the feature, defaults toTrue
.
- Returns
geopandas.GeoDataFrame
– The requested features as a GeoDataFrame.
- byids(field, fids, return_m=False, return_geom=True)#
Get features based on a list of field IDs.
- Parameters
- Returns
geopandas.GeoDataFrame
– The requested features as a GeoDataFrame.
- bysql(sql_clause, return_m=False, return_geom=True)#
Get feature IDs using a valid SQL 92 WHERE clause.
Notes
Not all web services support this type of query. For more details look here
- Parameters
- Returns
geopandas.GeoDataFrame
– The requested features as a GeoDataFrame.
- get_validlayers(url)#
Get a list of valid layers.
- property service_info#
Get the service information.
- class pynhd.core.GeoConnex(item=None)#
Access to the GeoConnex API.
Notes
The
geometry
field of the query can be a Polygon, MultiPolygon, or tuple/list of length 4 (bbox) inEPSG:4326
CRS. They should be within the extent of the GeoConnex endpoint.- Parameters
item (
str
, optional) – The target endpoint to query, defaults toNone
.
- property item#
Return the name of the endpoint.
- query(kwds, skip_geometry=False)#
Query the GeoConnex endpoint.
- class pynhd.core.ScienceBase#
Access and explore files on ScienceBase.
- static get_children(item)#
Get children items of an item.
- static get_file_urls(item)#
Get download and meta URLs of all the available files for an item.
- pynhd.core.stage_nhdplus_attrs(parquet_path=None)#
Stage the NHDPlus Attributes database and save to nhdplus_attrs.parquet.
More info can be found here.
- Parameters
parquet_path (
str
or~Path
) – Path to a file with.parquet
extension for saving the processed to disk for later use.- Returns
pandas.DataFrame
– The staged data as a DataFrame.