header_tag.html

Skip to contents

Construct WQP url for data retrieval. This function gets the data from here: https://www.waterqualitydata.us

Usage

constructWQPURL(siteNumbers, parameterCd, startDate, endDate, legacy = TRUE)

Arguments

siteNumbers

string or vector of strings USGS site number.

parameterCd

string or vector of USGS parameter code. This is usually an 5 digit number.

startDate

character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the earliest possible record.

endDate

character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the latest possible record.

legacy

Logical. If TRUE, uses legacy WQP services. Default is TRUE. Setting legacy = FALSE uses WQX3.0 WQP services, which are in-development, use with caution.

Value

url string

Examples

site_ids <- c("USGS-02292010", "USGS-02276877")
startDate <- "2020-01-01"
endDate <- ""
pCode <- c("80154", "00613")
url_wqp <- constructWQPURL(
  site_ids,
  pCode,
  startDate, endDate
)
url_wqp
#> <httr2_request>
#> GET
#> https://www.waterqualitydata.us/data/Result/search?siteid=USGS-02292010%3BUSGS-02276877&count=no&pCode=80154%3B00613&startDateLo=01-01-2020&mimeType=csv
#> Headers:
#>Accept-Encoding: 'compress'
#>Accept-Encoding: 'gzip'
#>Accept-Encoding: 'deflate'
#> Body: empty
charNames <- c(
  "Temperature",
  "Temperature, sample",
  "Temperature, water",
  "Temperature, water, deg F"
)
obs_url_orig <- constructWQPURL(
  siteNumbers = c(
    "IIDFG-41WSSPAHS",
    "USGS-02352560"
  ),
  parameterCd = charNames,
  startDate, ""
)
obs_url_orig
#> <httr2_request>
#> GET
#> https://www.waterqualitydata.us/data/Result/search?siteid=IIDFG-41WSSPAHS%3BUSGS-02352560&count=no&characteristicName=Temperature%3BTemperature%2C%20sample%3BTemperature%2C%20water%3BTemperature%2C%20water%2C%20deg%20F&startDateLo=01-01-2020&mimeType=csv
#> Headers:
#>Accept-Encoding: 'compress'
#>Accept-Encoding: 'gzip'
#>Accept-Encoding: 'deflate'
#> Body: empty