streamstats package

Submodules

streamstats.utils module

Utility functions for streamstats.

streamstats.utils.find_address(lat, lon)[source]

Find the address associated with a lat/lon pair.

Parameters
  • lat (float) – Latitude of point in decimal degrees

  • lon (float) – Longitude of point in decimal degrees

Return type

dictionary containing address data

streamstats.utils.find_state(address)[source]

Find the U.S. state that contains an address

Parameters

address (dict) – An address found by find_address

Return type

string of the state code (e.g., “CO” for Colorado)

streamstats.utils.requests_retry_session(retries=3, backoff=0.3, status_forcelist=(500, 502, 504))[source]

Make a session that backs off automatically.

Parameters
  • retries (int) – Number of times to retry a request

  • backoff (float) – Interval: {backoff} * (2^({number of total retries} - 1))

  • status_forcelist (tuple of ints) – Status codes that prompt a retry

streamstats.watershed module

Functionality for finding watershed information for specific locations.

class streamstats.watershed.Watershed(lat, lon)[source]

Bases: object

Watershed covering a spatial region, with associated information.

The USGS StreamStats API is built around watersheds as organizational units. Watersheds in the 50 U.S. states can be found using lat/lon lookups, along with information about the watershed including its HUC code and a GeoJSON representation of the polygon of a watershed. Basin characteristics can also be extracted from watersheds.

base_url = 'https://streamstats.usgs.gov/streamstatsservices/'
property boundary

Return the full watershed GeoJSON as a dictionary.

:rtype dict containing GeoJSON watershed boundary

property characteristics

List the available watershed characteristics.

Details about these characteristics can be found in the StreamStats docs: https://streamstatsags.cr.usgs.gov/ss_defs/basin_char_defs.aspx

:rtype OrderedDict with characteristic codes and descriptions

get_characteristic(code=None)[source]

Retrieve a specified watershed characteristic

Parameters

code (string) – Watershed characteristic code to extract.

get_characteristic() requires a characteristic code as an argument. Valid codes can be seen as keys in the dictionary returned by the characteristics() method.

:rtype dict containing specified characteristic’s data and metadata

property huc

Find the Hydrologic Unit Code (HUC) of the watershed.

Module contents

Top-level package for StreamStats.