pygeohydro.waterdata#
Accessing WaterData related APIs.
Module Contents#
- class pygeohydro.waterdata.SensorThings#
Class for interacting with SensorThings API.
- static odata_helper(columns=None, conditionals=None, expand=None, max_count=None, extra_params=None)#
Generate Odata filters for SensorThings API.
- Parameters:
columns (
list
ofstr
, optional) – Columns to be selected from the database, defaults toNone
.conditionals (
str
, optional) – Conditionals to be applied to the database, defaults toNone
. Note that the conditionals should have the form ofcond1 operator 'value' and/or cond2 operator 'value
. For example:properties/monitoringLocationType eq 'Stream' and ...
expand (
dict
ofdict
, optional) – Expand the properties of the selected columns, defaults toNone
. Note that theexpand
should have the form of{Property: {func: value, ...}}
. For example:{"Locations": {"select": "location", "filter": "ObservedProperty/@iot.id eq '00060'"}}
max_count (
int
, optional) – Maximum number of items to be returned, defaults toNone
.extra_params (
dict
, optional) – Extra parameters to be added to the Odata filter, defaults toNone
.
- Returns:
odata (
dict
) – Odata filter for the SensorThings API.- Return type:
- query_byodata(odata, outformat='json')#
Query the SensorThings API by Odata filter.
- Parameters:
- Returns:
pandas.DataFrame
orgeopandas.GeoDataFrame
– Requested data.- Return type:
- sensor_info(sensor_ids)#
Query the SensorThings API by a sensor ID.
- Parameters:
sensor_ids (
str
orlist
ofstr
) – A single or list of sensor IDs, e.g.,USGS-09380000
.- Returns:
pandas.DataFrame
– Requested sensor data.- Return type:
- sensor_property(sensor_property, sensor_ids)#
Query a sensor property.
- Parameters:
- Returns:
pandas.DataFrame
– A dataframe containing the requested property.- Return type:
- class pygeohydro.waterdata.WaterQuality#
Water Quality Web Service https://www.waterqualitydata.us.
Notes
This class has a number of convenience methods to retrieve data from the Water Quality Data. Since there are many parameter combinations that can be used to retrieve data, a general method is also provided to retrieve data from any of the valid endpoints. You can use
get_json
to retrieve stations info as ageopandas.GeoDataFrame
orget_csv
to retrieve stations data as apandas.DataFrame
. You can construct a dictionary of the parameters and pass it to one of these functions. For more information on the parameters, please consult the Water Quality Data documentation.- data_bystation(station_ids, wq_kwds)#
Retrieve data for a single station.
- Parameters:
- Returns:
pandas.DataFrame
– DataFrame of data for the stations.- Return type:
- get_csv(endpoint, kwds, request_method='GET')#
Get the CSV response from the Water Quality Web Service.
- Parameters:
- Returns:
pandas.DataFrame
– The web service response as a DataFrame.- Return type:
- get_json(endpoint, kwds, request_method='GET')#
Get the JSON response from the Water Quality Web Service.
- Parameters:
- Returns:
geopandas.GeoDataFrame
– The web service response as a GeoDataFrame.- Return type:
- get_param_table()#
Get the parameter table from the USGS Water Quality Web Service.
- lookup_domain_values(endpoint)#
Get the domain values for the target endpoint.
- station_bybbox(bbox, wq_kwds)#
Retrieve station info within bounding box.
- Parameters:
- Returns:
geopandas.GeoDataFrame
– GeoDataFrame of station info within the bounding box.- Return type:
- station_bydistance(lon, lat, radius, wq_kwds)#
Retrieve station within a radius (decimal miles) of a point.
- Parameters:
- Returns:
geopandas.GeoDataFrame
– GeoDataFrame of station info within the radius of the point.- Return type: