API Reference

Documentation for DataRetrieval.jl's public functions.

Index

NWIS Functions

Functions that are related to the National Water Information System(NWIS).

DataRetrieval.readNWISFunction
readNWIS(obs_url)

Function to take an NWIS url (typically constructed using the constructNWISURL() function) and return the associated data.

source
DataRetrieval.readNWISdvFunction
readNWISdv(siteNumbers, parameterCd;
           startDate="", endDate="", statCd="00003", format="rdb")

Function to obtain daily value data from the NWIS web service.

Examples

julia> df, response = readNWISdv("01646500", "00060",
                                 startDate="2010-10-01", endDate="2010-10-01");

julia> df  # df contains the formatted data as a DataFrame
1×5 DataFrame
 Row │ agency_cd  site_no   datetime    68478_00060_00003  68478_00060_00003_c ⋯
     │ String7    String15  String15    String7            String3             ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ USGS       01646500  2010-10-01  13100              A                   ⋯
                                                                1 column omitted
julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.readNWISpCodeFunction
readNWISpCode(parameterCd)

Function to obtain parameter code information from the NWIS web service. As currently implemented, support for multiple parameter codes is not included.

Examples

julia> df, response = readNWISpCode("00060");

julia> df  # df contains the formatted data as a DataFrame
1×13 DataFrame
 Row │ parameter_cd  group     parm_nm                           epa_equivalen ⋯
     │ String7       String15  String                            String15      ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ 00060         Physical  Discharge, cubic feet per second  Not checked   ⋯
                                                              10 columns omitted

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.readNWISqwFunction
readNWISqw(siteNumbers;
           startDate="", endDate="", format="rdb", expanded=true)

Function to obtain water quality data from the NWIS web service.

source
DataRetrieval.readNWISsiteFunction
readNWISsite(siteNumbers)

Function to obtain site information from the NWIS web service.

Examples

julia> df, response = readNWISsite("05114000");

julia> df  # df contains the formatted data as a DataFrame
1×12 DataFrame
 Row │ agency_cd  site_no   station_nm                    site_tp_cd  dec_lat_ ⋯
     │ String7    String15  String31                      String3     String15 ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ USGS       05114000  SOURIS RIVER NR SHERWOOD, ND  ST          48.99001 ⋯
                                                               8 columns omitted

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.readNWISunitFunction
readNWISunit(siteNumbers, parameterCd;
             startDate="", endDate="", format="rdb")

Function to obtain instantaneous value data from the NWIS web service.

Examples

julia> df, response = readNWISunit("01646500", "00060",
                                   startDate="2022-12-29",
                                   endDate="2022-12-29");

julia> first(df)  # df contains the formatted data as a DataFrame
DataFrameRow
 Row │ agency_cd  site_no   datetime          tz_cd    69928_00060  69928_0006 ⋯
     │ String7    String15  String31          String3  String7      String3    ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ USGS       01646500  2022-12-29 00:00  EST      12700        P          ⋯
                                                                1 column omitted

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source

WQP Functions

Functions that are related to the Water Quality Portal.

DataRetrieval.readWQPdataFunction
readWQPdata(service; kwargs...)

Flexible querying of the WQP. See other functions for specific queries.

Arguments

  • service::String: The WQP service to query. One of "Result", "Station", "Organization", "Project", "Activity", "ResultDetectionQuantitationLimit", "BiologicalMetric", "ProjectMonitoringLocationWeighting", or "ActivityMetric".

Keyword Arguments

  • siteid::String: Concatenate an agency code, a hyphen ("-"), and a site-identification number.
  • statecode::String: State code to search within. Concatenate 'US', a colon (":"), and a FIPS numeric code (Example: Illinois is US:17).
  • countycode::String: FIPS county code to search within.
  • huc::String: One or more eight-digit HUC codes, delimited by semicolons.
  • bBox::String: Bounding box to search within. Format is "minx,miny,maxx,maxy" (Example: bBox="-92.8,44.2,-88.9,46.0").
  • lat::String: Latitude for radial search in decimal degrees, WGS84.
  • long::String: Longitude for radial search in decimal degrees, WGS84.
  • within::String: Distance for radial search in decimal miles.
  • pCode::String: One or more five-digit USGS parameter codes, delimited by semicolons.
  • startDateLo::String: Start date for search in MM-DD-YYYY format.
  • startDateHi::String: End date for search in MM-DD-YYYY format.
  • characteristicName::String: One or more characteristic names, delimited by semicolons. (See https://www.waterqualitydata.us/public_srsnames/ for available characteristic names).

Examples

julia> df, response = readWQPdata("Result",
                                  lat="44.2", long="-88.9", within="0.5");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ActivityIdentifier
     │ InlineStrings.String15  String                             String31
─────┼───────────────────────────────────────────────────────────────────────────────
   1 │ WIDNR_WQX               Wisconsin Department of Natural …  WIDNR_WQX-35940585

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.readWQPresultsFunction
readWQPresults(; kwargs...)

Query the WQP for results.

Examples

julia> df, response = readWQPresults(lat="44.2", long="-88.9", within="0.5");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ActivityIdentifier
     │ InlineStrings.String15  String                             String31
─────┼───────────────────────────────────────────────────────────────────────────────
   1 │ WIDNR_WQX               Wisconsin Department of Natural …  WIDNR_WQX-35940585

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPsitesFunction
whatWQPsites(; kwargs...)

Function to search WQP for sites within a region with specific data.

Examples

julia> df, response = whatWQPsites(lat="44.2", long="-88.9", within="2.5");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             MonitoringLocationIdentifier
     │ InlineStrings.String15  String                             InlineStrings.String31
─────┼─────────────────────────────────────────────────────────────────────────────────────────
   1 │ USGS-WI                 USGS Wisconsin Water Science Cen…  USGS-441159088505801

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPorganizationsFunction
whatWQPorganizations(; kwargs...)

Function to search WQP for organizations within a region with specific data.

Examples

julia> df, response = whatWQPorganizations(huc="12");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName         OrganizationDescriptionText
     │ InlineStrings.String31  String                         Union{Missing, String}
─────┼────────────────────────────────────────────────────────────────────────────────────
   1 │ ARS                     Agricultural Research Service  missing

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPprojectsFunction
whatWQPprojects(; kwargs...)

Function to search WQP for projects within a region with specific data.

Examples

julia> df, response = whatWQPprojects(huc="19");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ProjectIdentifier
     │ InlineStrings.String31  String                             String
─────┼──────────────────────────────────────────────────────────────────────────────
   1 │ 21AKBCH                 Alaska Department of Environment…  AK164406

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPactivitiesFunction
whatWQPactivities(; kwargs...)

Function to search WQP for activities within a region with specific data.

Examples

julia> df, response = whatWQPactivities(statecode="US:11",
                                        startDateLo="12-30-2019",
                                        startDateHi="01-01-2020");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ActivityIdentifier
     │ InlineStrings.String7   String                             String31
─────┼───────────────────────────────────────────────────────────────────────────────
   1 │ USGS-MD                 USGS Maryland Water Science Cent…  nwismd.01.02000322

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPdetectionLimitsFunction
whatWQPdetectionLimits(; kwargs...)

Function to search WQP for detection limits within a region with specific data.

Examples

julia> df, response = whatWQPdetectionLimits(statecode="US:44",
                                             characteristicName="Nitrite",
                                             startDateLo="01-01-2021",
                                             startDateHi="02-20-2021");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ActivityIdentifier
     │ InlineStrings.String7   String                             String31
─────┼───────────────────────────────────────────────────────────────────────────────
   1 │ USGS-MA                 USGS Massachusetts Water Science…  nwisma.01.02100548

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPhabitatMetricsFunction
whatWQPhabitatMetrics(; kwargs...)

Function to search WQP for habitat metrics within a region with specific data.

Examples

julia> df, response = whatWQPhabitatMetrics(statecode="US:44");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  MonitoringLocationIdentifier  IndexIdentifier
     │ InlineStrings.String15  InlineStrings.String31        String
─────┼───────────────────────────────────────────────────────────────────────────────
   1 │ NARS_WQX                NARS_WQX-NEWS04-4201          PH:NEWS04-4201:1:BKA_Q3

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPprojectWeightsFunction
whatWQPprojectWeights(; kwargs...)

Function to search WQP for project weights within a region with specific data.

Examples

julia> df, response = whatWQPprojectWeights(statecode="US:38",
                                            startDateLo="01-01-2006",
                                            startDateHi="01-01-2008");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName             ProjectIdentifier
     │ InlineStrings.String15  String                             String31
─────┼───────────────────────────────────────────────────────────────────────────────────────
   1 │ NARS_WQX                EPA National Aquatic Resources S…  NARS_NLA2007_ECOREGION_NPL

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.whatWQPactivityMetricsFunction
whatWQPactivityMetrics(; kwargs...)

Function to search WQP for activity metrics within a region with specific data.

Examples

julia> df, response = whatWQPactivityMetrics(statecode="US:38",
                                             startDateLo="07-01-2006",
                                             startDateHi="12-01-2006");

julia> first(df)[1:3]
DataFrameRow
 Row │ OrganizationIdentifier  OrganizationFormalName        MonitoringLocationIdentifier
     │ InlineStrings.String15  InlineStrings.String31        InlineStrings.String31
─────┼────────────────────────────────────────────────────────────────────────────────────
   1 │ EMAP_GRE                EMAP-Great Rivers Ecosystems  EMAP_GRE-GRE06604-1268

julia> typeof(response)  # response is the unmodified HTTP GET response object
HTTP.Messages.Response
source
DataRetrieval.constructNWISURLFunction
constructNWISURL(siteNumbers; parameterCd="00060",
    startDate="", endDate="", service="site", statCd="00003",
    format="xml", expanded=True, ratingType="base", statReportType="daily",
    statType="mean")

Construct a URL to be used to make an API query to the NWIS service.

source