Skip to content
Snippets Groups Projects
constructNWISURL.Rd 3.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • % Generated by roxygen2 (4.0.2): do not edit by hand
    
    \name{constructNWISURL}
    \alias{constructNWISURL}
    \title{Construct NWIS url for data retrieval}
    \usage{
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    constructNWISURL(siteNumber, parameterCd = "00060", startDate = "",
      endDate = "", service, statCd = "00003", format = "xml",
      expanded = FALSE, ratingType = "base")
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    \item{siteNumber}{string or vector of strings USGS site number.  This is usually an 8 digit number}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    \item{parameterCd}{string or vector of USGS parameter code.  This is usually an 5 digit number.}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    \item{startDate}{string starting date for data retrieval in the form YYYY-MM-DD.}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    \item{endDate}{string ending date for data retrieval in the form YYYY-MM-DD.}
    
    \item{service}{string USGS service to call. Possible values are "dv" (daily values), "uv" (unit/instantaneous values),
    "qw" (water quality data), "gwlevels" (groundwater),and "rating" (rating curve), "peak", "meas" (discrete streamflow measurements).}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    
    
    \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's avatar
    Laura A DeCicco committed
    \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,
    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's avatar
    Laura A DeCicco committed
    \item{expanded}{logical defaults to FALSE. If TRUE, retrieves additional information, only applicable for qw data.}
    
    
    \item{ratingType}{can be "base", "corr", or "exsa". Only applies to rating curve data.}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    url string
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    Imports data from NWIS web service. This function gets the data from here: \url{http://nwis.waterdata.usgs.gov/nwis/qwdata}
    A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
    A list of statistic codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    siteNumber <- '01594440'
    startDate <- '1985-01-01'
    endDate <- ''
    
    url_daily <- constructNWISURL(siteNumber,pCode,
               startDate,endDate,'dv',statCd=c("00003","00001"))
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    url_unit <- constructNWISURL(siteNumber,pCode,"2012-06-28","2012-06-30",'iv')
    
    Laura A DeCicco's avatar
    Laura A DeCicco committed
    url_qw_single <- constructNWISURL(siteNumber,"01075",startDate,endDate,'qw')
    
    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")
    
    url_rating <- constructNWISURL(siteNumber,service="rating",ratingType="base")
    url_peak <- constructNWISURL(siteNumber, service="peak")
    url_meas <- constructNWISURL(siteNumber, service="meas")
    
    \keyword{data}
    \keyword{import}
    \keyword{service}
    \keyword{web}