constructNWISURL.Rd 4.31 KB
 Laura A DeCicco committed Nov 09, 2015 1 % Generated by roxygen2: do not edit by hand  Laura A DeCicco committed Dec 31, 2014 2 % Please edit documentation in R/constructNWISURL.r  3 4 5 6 \name{constructNWISURL} \alias{constructNWISURL} \title{Construct NWIS url for data retrieval} \usage{  Laura A DeCicco committed Nov 07, 2014 7 8 constructNWISURL(siteNumber, parameterCd = "00060", startDate = "", endDate = "", service, statCd = "00003", format = "xml",  David Watkins committed Jun 17, 2016 9 10  expanded = TRUE, ratingType = "base", statReportType = "daily", statType = "mean")  11 12 } \arguments{  Laura A DeCicco committed Jun 18, 2014 13 \item{siteNumber}{string or vector of strings USGS site number. This is usually an 8 digit number}  14   Laura A DeCicco committed Jun 18, 2014 15 \item{parameterCd}{string or vector of USGS parameter code. This is usually an 5 digit number.}  16   Laura A DeCicco committed Dec 02, 2014 17 18 \item{startDate}{character starting date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the earliest possible record.}  19   Laura A DeCicco committed Dec 02, 2014 20 21 \item{endDate}{character ending date for data retrieval in the form YYYY-MM-DD. Default is "" which indicates retrieval for the latest possible record.}  22   Laura A DeCicco committed Nov 09, 2015 23 \item{service}{string USGS service to call. Possible values are "dv" (daily values), "uv" (unit/instantaneous values),  Laura A DeCicco committed Aug 02, 2016 24 25 "qw" (water quality data), "gwlevels" (groundwater),and "rating" (rating curve), "peak", "meas" (discrete streamflow measurements), "stat" (statistics web service BETA).}  Laura A DeCicco committed Mar 28, 2013 26   Laura A DeCicco committed Sep 09, 2014 27 28 \item{statCd}{string or vector USGS statistic code only used for daily value service. This is usually 5 digits. Daily mean (00003) is the default.}  Laura A DeCicco committed Nov 09, 2015 29 30 \item{format}{string, can be "tsv" or "xml", and is only applicable for daily and unit value requests. "tsv" returns results faster, but there is a possiblitiy that an incomplete file is returned without warning. XML is slower, but will offer a warning if the file was incomplete (for example, if there was a momentary problem with the internet connection). It is possible to safely use the "tsv" option,  Laura A DeCicco committed Jun 18, 2014 31 but the user must carefully check the results to see if the data returns matches what is expected. The default is therefore "xml".}  Laura A DeCicco committed Apr 08, 2013 32   Laura A DeCicco committed Dec 02, 2014 33 \item{expanded}{logical defaults to \code{TRUE}. If \code{TRUE}, retrieves additional information, only applicable for qw data.}  Laura A DeCicco committed Oct 28, 2014 34 35  \item{ratingType}{can be "base", "corr", or "exsa". Only applies to rating curve data.}  David Watkins committed Jul 07, 2016 36 37 38 39 40  \item{statReportType}{character Only used for statistics service requests. Time division for statistics: daily, monthly, or annual. Default is daily. Note that daily provides statistics for each calendar day over the specified range of water years, i.e. no more than 366 data points will be returned for each site/parameter. Use readNWISdata or readNWISdv for daily averages. Also note that 'annual' returns statistics for the calendar year. Use readNWISdata for water years. Monthly and yearly  Laura A DeCicco committed Aug 02, 2016 41 provide statistics for each month and year within the range individually.}  David Watkins committed Jul 07, 2016 42 43 44  \item{statType}{character Only used for statistics service requests. Type(s) of statistics to output for daily values. Default is mean, which is the only option for monthly and yearly report types. See the statistics service documentation  Laura A DeCicco committed Dec 14, 2016 45 at \url{https://waterservices.usgs.gov/rest/Statistics-Service.html#statType} for a full list of codes.}  46 47 } \value{  Laura A DeCicco committed Jun 18, 2014 48 url string  49 50 } \description{  Laura A DeCicco committed Dec 14, 2016 51 52 53 Imports data from NWIS web service. This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/qwdata} A list of parameter codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes/} A list of statistic codes can be found here: \url{https://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}  54 55 } \examples{  Laura A DeCicco committed Apr 08, 2013 56 57 58 siteNumber <- '01594440' startDate <- '1985-01-01' endDate <- ''  59 pCode <- c("00060","00010")  Laura A DeCicco committed Nov 13, 2014 60 61 url_daily <- constructNWISURL(siteNumber,pCode, startDate,endDate,'dv',statCd=c("00003","00001"))  Laura A DeCicco committed Nov 12, 2014 62 63 url_unit <- constructNWISURL(siteNumber,pCode,"2012-06-28","2012-06-30",'iv')  Laura A DeCicco committed Apr 08, 2013 64 url_qw_single <- constructNWISURL(siteNumber,"01075",startDate,endDate,'qw')  Laura A DeCicco committed Sep 11, 2014 65 66 67 68 url_qw <- constructNWISURL(siteNumber,c('01075','00029','00453'), startDate,endDate,'qw') url_daily_tsv <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv', statCd=c("00003","00001"),format="tsv")  Laura A DeCicco committed Oct 28, 2014 69 70 71 url_rating <- constructNWISURL(siteNumber,service="rating",ratingType="base") url_peak <- constructNWISURL(siteNumber, service="peak") url_meas <- constructNWISURL(siteNumber, service="meas")  Laura A DeCicco committed Oct 14, 2015 72 urlQW <- constructNWISURL("450456092225801","70300",startDate="",endDate="","qw",expanded=TRUE)  73 }  Laura A DeCicco committed Aug 01, 2013 74 \keyword{USGS}  75 76 77 78 79 \keyword{data} \keyword{import} \keyword{service} \keyword{web}