readNWISodbc: Function to pull data from NWIS

Description Usage Arguments Details Value Examples

View source: R/readNWISodbc.R

Description

Pulls data from NWIS internal servers using ODBC connection and returns a list containing dataframes.

Usage

1
2
3
readNWISodbc(DSN, env.db = "01", qa.db = "02", STAIDS,
  dl.parms = "All", parm.group.check = TRUE, begin.date = NA,
  end.date = NA, projectCd = NULL, resultAsText = FALSE)

Arguments

DSN

A character string containing the DSN for your local server

env.db

A character string containing the database number of environmental samples

qa.db

A character string containing the database number of QA samples

STAIDS

A character vector of stations IDs. Agency code defaults to "USGS" unless appended to the beginning of station ID with a dash, e.g. "USGS-123456".

dl.parms

A character vector of pcodes to pull data, e.g. c("00300","00915") or NWIS parameter groups specified in details section.

parm.group.check

A logical of whether or not to use NWIS parameter groups. If TRUE, must use NWIS parameter group names in dl.parms

begin.date

Character string containing beginning date of data pull (yyyy-mm-dd)

end.date

Character string containing ending date of data pull (yyyy-mm-dd)

projectCd

Character vector containing project codes to subset data by.

resultAsText

Output results as character instead of numeric. Used for literal output of results from NWIS that are no affected by class coerrcion, such as dropping zeros after decimal point. Default is False.

Details

NWIS parameter groups are as follows: All = "All", physical = "PHY", cations = "INM", anions = "INN", nutrients = "NUT", microbiological = "MBI", biological = "BIO", metals = "IMM", nonmetals = "IMN", pesticides = "TOX", pcbs="OPE", other organics = "OPC", radio chemicals = "RAD", stable isotopes = "XXX", sediment = "SED", population/community = "POP"

Value

Returns a list containing two dataframes: PlotTable and DataTable. PlotTable contains all data pulled from NWIS along with all assosciated metadata in by-result format. DataTable contains all data pulled from NWIS in wide (sample-result) format, an easier format for import into spreadsheet programs. Dataframe names will be changed to more appropriate values in future package updates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
#Will not run unless connected to NWISCO
qw.data <- readNWISodbc(DSN="NWISCO",
                             env.db = "01",
                             qa.db = "02",
                             STAIDS = c("06733000","09067005"),
                             dl.parms="All",
                             parm.group.check=TRUE,
                             begin.date = "2005-01-01",
                             end.date = "2015-10-27",
                             projectCd = NULL)
                             
## End(Not run)

USGS-R/WQ-Review documentation built on Nov. 12, 2019, 9:51 a.m.