dataretrieval.streamstats

This module is a wrapper for the streamstats API (streamstats documentation).

class dataretrieval.streamstats.Watershed(rcode, xlocation, ylocation)[source]

Class to extract information from the streamstats JSON object.

__init__(rcode, xlocation, ylocation)[source]

Init method that calls the from_streamstats_json method.

__weakref__

list of weak references to the object (if defined)

classmethod from_streamstats_json(streamstats_json)[source]

Method that creates a Watershed object from a streamstats JSON.

dataretrieval.streamstats.download_workspace(workspaceID, format='')[source]

Function to download streamstats workspace.

Parameters:
  • workspaceID (string) – Service workspace received from watershed result

  • format (string) – Download return format. Default will return ESRI geodatabase zipfile. ‘SHAPE’ will return a zip file containing shape format.

Returns:

r – A zip file containing the workspace contents, in either a geodatabase or shape files.

Return type:

geodatabase or shapefiles

dataretrieval.streamstats.get_sample_watershed()[source]

Sample function to get a watershed object for a location in NY.

Makes the function call dataretrieval.streamstats.get_watershed with the parameters ‘NY’, -74.524, 43.939, and returns the watershed object.

Returns:

Watershed – Custom object that contains the watershed information as extracted from the streamstats JSON object.

Return type:

dataretrieval.streamstats.Watershed

dataretrieval.streamstats.get_watershed(rcode, xlocation, ylocation, crs=4326, includeparameters=True, includeflowtypes=False, includefeatures=True, simplify=True, format='geojson')[source]

Get watershed object based on location

Streamstats documentation: Returns a watershed object. The request configuration will determine the overall request response. However all returns will return a watershed object with at least the workspaceid. The workspace id is the id to the service workspace where files are stored and can be used for further processing such as for downloads and flow statistic computations.

See: https://streamstats.usgs.gov/streamstatsservices/#/ for more information.

Parameters:
  • rcode (string) – StreamStats 2-3 character code that identifies the Study Area – either a State or a Regional Study.

  • xlocation (float) – X location of the most downstream point of desired study area.

  • ylocation (float) – Y location of the most downstream point of desired study area.

  • crs (integer, string, optional) – ESPSG spatial reference code, default is 4326

  • includeparameters (bool, optional) – Boolean flag to include parameters in response.

  • includeflowtypes (bool, string, optional) – Not yet implemented. Would be a comma separated list of region flow types to compute with the default being True

  • includefeatures (list, optional) – Comma separated list of features to include in response.

  • simplify (bool, optional) – Boolean flag controlling whether or not to simplify the returned result.

Returns:

Watershed – Custom object that contains the watershed information as extracted from the streamstats JSON object.

Return type:

dataretrieval.streamstats.Watershed