Imports data from NWIS web service.
Inputs to this function are USGS site ids, USGS parameter codes,
and start and end date. For a more complex query, use readNWISdata(),
including an arguement service="uv".
Not all parameter codes are available for all data.
Use the function whatNWISdata() to discover what data
is available for a USGS site. The column data_type_cd with the values "uv"
returned from whatNWISdata()) are available from this service.
Usage
readNWISuv(
siteNumbers,
parameterCd,
startDate = "",
endDate = "",
tz = "UTC",
override_error = FALSE
)Arguments
- siteNumbers
character USGS site number (or multiple sites). This is usually an 8 digit number
- parameterCd
character 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. Simple date arguments are specified in local time.
- endDate
character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the latest possible record. Simple date arguments are specified in local time.
- tz
character to set timezone attribute of dateTime. Default is "UTC", and converts the date times to UTC, properly accounting for daylight savings times based on the data provided tz_cd column. Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu", "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also
OlsonNames()for more information on time zones.- override_error
Logical parameter that allows users to run this function during the final stages of NWIS decommission. NWIS servers will be taken offline February 22nd, 2027. Setting this parameter to
TRUEshould only be used as a tool to convert readNWIS to read_waterdata functions.
Value
A data frame with the following columns:
| Name | Type | Description |
| agency_cd | character | The NWIS code for the agency reporting the data |
| site_no | character | The USGS site number |
| dateTime | POSIXct | The date and time of the value converted to UTC |
| tz_cd | character | The time zone code for dateTime |
| code | character | Any codes that qualify the corresponding value |
| value | numeric | The numeric value for the parameter |
Note that code and value are repeated for the parameters requested. The names are of the form: X_D_P_S, where X is literal, D is an option description of the parameter, P is the parameter code, and S is the statistic code (if applicable).
There are also several useful attributes attached to the data frame:
| Name | Type | Description |
| url | character | The url used to generate the data |
| siteInfo | data.frame | A data frame containing information on the requested sites |
| variableInfo | data.frame | A data frame containing information on the requested parameters |
| statisticInfo | data.frame | A data frame containing information on the requested statistics on the data |
| queryTime | POSIXct | The time the data was returned |
