11# ' Instantaneous value data retrieval from USGS (NWIS)
22# '
3- # ' Imports data from NWIS web service. This function gets the data from here:
4- # ' <https://waterservices.usgs.gov/docs/instantaneous-values/instantaneous-values-details/>
5- # ' Inputs to this function are just USGS site ids, USGS parameter codes,
3+ # ' Imports data from NWIS web service.
4+ # ' Inputs to this function are USGS site ids, USGS parameter codes,
65# ' and start and end date. For a more complex query, use [readNWISdata()],
76# ' including an arguement service="uv".
87# ' Not all parameter codes are available for all data.
98# ' Use the function [whatNWISdata()] to discover what data
109# ' is available for a USGS site. The column data_type_cd with the values "uv"
1110# ' returned from [whatNWISdata()]) are available from this service.
1211# '
13- # ' More information on the web service can be found here:
14- # ' <https://waterservices.usgs.gov/test-tools>, choosing the
15- # ' "Instantaneous Value Service".
1612# '
1713# ' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
1814# ' @param parameterCd character USGS parameter code. This is usually an 5 digit number.
1915# ' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
2016# ' retrieval for the earliest possible record. Simple date arguments are specified in local time.
21- # ' See more information here: <https://waterservices.usgs.gov/docs/instantaneous-values/>.
2217# ' @param endDate character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
2318# ' retrieval for the latest possible record. Simple date arguments are specified in local time.
24- # ' See more information here: <https://waterservices.usgs.gov/docs/instantaneous-values/>.
2519# ' @param tz character to set timezone attribute of dateTime. Default is "UTC", and converts the
26- # ' date times to UTC, properly accounting for daylight savings times based on the data's provided tz_cd column.
20+ # ' date times to UTC, properly accounting for daylight savings times based on the data provided tz_cd column.
2721# ' Possible values to provide are "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles",
2822# ' "America/Anchorage", as well as the following which do not use daylight savings time: "America/Honolulu",
2923# ' "America/Jamaica", "America/Managua", "America/Phoenix", and "America/Metlakatla". See also `OlsonNames()`
@@ -91,9 +85,9 @@ readNWISuv <- function(siteNumbers, parameterCd, startDate = "", endDate = "", t
9185 service <- " iv_recent"
9286 }
9387
94- # .Deprecated(new = "read_waterdata_continuous",
95- # package = "dataRetrieval",
96- # msg = "NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_continuous.")
88+ .Deprecated(new = " read_waterdata_continuous" ,
89+ package = " dataRetrieval" ,
90+ msg = " NWIS servers are slated for decommission. Please begin to migrate to read_waterdata_continuous." )
9791
9892
9993 url <- constructNWISURL(siteNumbers ,
@@ -111,8 +105,8 @@ readNWISuv <- function(siteNumbers, parameterCd, startDate = "", endDate = "", t
111105
112106# ' Peak flow data from USGS (NWIS)
113107# '
114- # ' Reads peak flow from NWISweb. Data is retrieved from
115- # ' <https://waterdata.usgs.gov/nwis>.
108+ # ' Reads peak flow from NWISweb.
109+ # '
116110# ' In some cases, the specific date of the peak data is not know. This function
117111# ' will default to
118112# ' converting complete dates to a "Date" object, and converting incomplete dates to
@@ -233,7 +227,6 @@ readNWISpeak <- function(siteNumbers,
233227# ' Rating table for an active USGS streamgage retrieval
234228# '
235229# ' Reads current rating table for an active USGS streamgage from NWISweb.
236- # ' Data is retrieved from <https://waterdata.usgs.gov/nwis>.
237230# '
238231# ' @param siteNumber character USGS site number. This is usually an 8 digit number
239232# ' @param type character can be "base", "corr", or "exsa"
@@ -304,8 +297,7 @@ readNWISrating <- function(siteNumber, type = "base", convertType = TRUE) {
304297
305298# ' Surface-water measurement data retrieval from USGS (NWIS)
306299# '
307- # ' Reads surface-water measurement data from NWISweb. Data is retrieved from <https://waterdata.usgs.gov/nwis>.
308- # ' See <https://waterdata.usgs.gov/usa/nwis/sw> for details about surface water.
300+ # ' Reads surface-water measurement data from NWISweb.
309301# '
310302# ' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
311303# ' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
@@ -334,9 +326,6 @@ readNWISrating <- function(siteNumber, type = "base", convertType = TRUE) {
334326# ' tz_cd \tab character \tab The time zone code for the measurement_dt column \cr
335327# ' }
336328# '
337- # ' See <https://waterdata.usgs.gov/usa/nwis/sw> for details about surface water, and
338- # ' <https://waterdata.usgs.gov/nwis/help?output_formats_help>
339- # ' for help on the columns and codes.
340329# '
341330# ' There are also several useful attributes attached to the data frame:
342331# ' \tabular{lll}{
@@ -438,8 +427,7 @@ readNWISmeas <- function(siteNumbers,
438427
439428# ' Groundwater level measurements retrieval from USGS (NWIS)
440429# '
441- # ' Imports groundwater level data from NWIS web service. This function gets the data from here:
442- # ' <https://waterservices.usgs.gov/docs/groundwater-levels/groundwater-levels-details/>
430+ # ' Imports groundwater level data from NWIS web service.
443431# ' Inputs to this function are just USGS site ids, USGS parameter codes,
444432# ' and start and end date. For a more complex query, use [readNWISdata()],
445433# ' including an argument service="gwlevels".
@@ -448,16 +436,7 @@ readNWISmeas <- function(siteNumbers,
448436# ' is available for a USGS site. The column data_type_cd with the values "gw"
449437# ' returned from [whatNWISdata()]) are available from this service.
450438# '
451- # ' More information on the web service can be found here:
452- # ' <https://waterservices.usgs.gov/test-tools>, choosing the
453- # ' "Groundwater Levels Value Service".
454- # '
455439# '
456- # ' Mixed date/times come back from the service
457- # ' depending on the year that the data was collected. See <https://waterdata.usgs.gov/usa/nwis/gw>
458- # ' for details about groundwater. By default the returned dates are converted to date objects, unless convertType
459- # ' is specified as FALSE. Sites with non-standard date formats (i.e. lacking a day) can be affected (see examples).
460- # ' See <https://waterservices.usgs.gov/docs/groundwater-levels/> for more information.
461440# '
462441# ' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number
463442# ' @param startDate character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates
@@ -569,7 +548,6 @@ readNWISgwl <- function(siteNumbers,
569548# ' Site statistics retrieval from USGS (NWIS)
570549# '
571550# ' Retrieves site statistics from the USGS Statistics Web Service beta.
572- # ' See <https://waterservices.usgs.gov/docs/statistics/> for more information.
573551# '
574552# ' @param siteNumbers character USGS site number (or multiple sites). This is usually an 8 digit number.
575553# ' @param parameterCd character USGS parameter code. This is usually a 5 digit number.
@@ -593,9 +571,7 @@ readNWISgwl <- function(siteNumbers,
593571# ' for water years. Monthly and yearly
594572# ' provide statistics for each month and year within the range indivually.
595573# ' @param statType character type(s) of statistics to output for daily values.
596- # ' Default is mean, which is the only
597- # ' option for monthly and yearly report types. See the statistics service documentation
598- # ' at <https://waterservices.usgs.gov/docs/statistics/> for a full list of codes.
574+ # ' Default is mean, which is the only option for monthly and yearly report types.
599575# ' @return A data frame with the following columns:
600576# ' \tabular{lll}{
601577# ' Name \tab Type \tab Description \cr
@@ -679,9 +655,7 @@ readNWISstat <- function(siteNumbers, parameterCd, startDate = "", endDate = "",
679655
680656# ' Water use data retrieval from USGS (NWIS)
681657# '
682- # ' Retrieves water use data from USGS Water Use Data for the Nation. See
683- # ' <https://waterdata.usgs.gov/nwis/wu> for
684- # ' more information. All available use categories for the supplied arguments are retrieved.
658+ # ' Retrieves water use data from USGS Water Use Data for the Nation.
685659# '
686660# ' @param stateCd could be character (full name, abbreviation, id), or numeric (id).
687661# ' Only one is accepted per query.
@@ -711,81 +685,17 @@ readNWISstat <- function(siteNumbers, parameterCd, startDate = "", endDate = "",
711685# ' County and state fields will be included as appropriate.
712686# '
713687# ' @export
714- # ' @examplesIf is_dataRetrieval_user()
715- # ' \donttest{
716- # ' # All data for a county
717- # ' allegheny <- readNWISuse(stateCd = "Pennsylvania", countyCd = "Allegheny")
718- # '
719- # ' # Data for an entire state for certain years
720- # ' ohio <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "OH", countyCd = NULL)
721- # '
722- # ' # Data for an entire state, county by county
723- # ' pr <- readNWISuse(years = c(2000, 2005, 2010), stateCd = "PR", countyCd = "ALL")
724- # '
725- # ' # All national-scale data, transforming data frame to named columns from named rows
726- # ' national <- readNWISuse(stateCd = NULL, countyCd = NULL, transform = TRUE)
727- # '
728- # ' # Washington, DC data
729- # ' dc <- readNWISuse(stateCd = "DC", countyCd = NULL)
730- # '
731- # ' # data for multiple counties, with different input formatting
732- # ' paData <- readNWISuse(stateCd = "42", countyCd = c("Allegheny County", "BUTLER", 1, "031"))
733- # '
734- # ' # retrieving two specific categories for an entire state
735- # ' ks <- readNWISuse(stateCd = "KS", countyCd = NULL, categories = c("IT", "LI"))
736- # ' }
737688readNWISuse <- function (stateCd ,
738689 countyCd ,
739690 years = " ALL" ,
740691 categories = " ALL" ,
741692 convertType = TRUE ,
742693 transform = FALSE ) {
743- message(new_nwis_message())
744- countyID <- NULL
745- countyCd <- countyCd [countyCd != " " ]
746-
747- if (exists(" countyCd" ) && ! is.null(countyCd )) {
748- if (! any(toupper(countyCd ) == " ALL" )) {
749- for (c in countyCd ) {
750- code <- countyCdLookup(state = stateCd , county = c , outputType = " id" )
751- countyID <- c(countyID , code )
752- }
753- } else {
754- countyID <- toupper(countyID )
755- }
756- }
757-
758- years <- .capitalALL(years )
759- categories <- .capitalALL(categories )
760-
761- url <- constructUseURL(
762- years = years ,
763- stateCd = stateCd ,
764- countyCd = countyID ,
765- categories = categories
766- )
767- returned_data <- importRDB1(
768- obs_url = url ,
769- convertType = convertType
770- )
694+ .Deprecated(new = " read_waterdata_use_data in development" ,
695+ package = " dataRetrieval" ,
696+ msg = " NWIS servers for water use have been decommission. New functions are being developed." )
697+ return (NULL )
771698
772- # for total country data arriving in named rows
773- if (transform ) {
774- cmmnt <- comment(returned_data )
775- returned_data <- t(returned_data )
776- colnames(returned_data ) <- returned_data [1 , ]
777- returned_data <- as.data.frame(returned_data [- 1 , ], stringsAsFactors = FALSE )
778- returned_data <- cbind(
779- Year = as.integer(substr(rownames(returned_data ), 2 , 5 )),
780- returned_data
781- )
782- rownames(returned_data ) <- NULL
783- comment(returned_data ) <- cmmnt
784- if (! all(is.null(stateCd )) && all(nchar(stateCd ) != 0 )) {
785- warning(" transform = TRUE is only intended for national data" )
786- }
787- }
788- return (returned_data )
789699}
790700
791701.capitalALL <- function (input ) {
0 commit comments