Query soil/climate data from USDA-NRCS SCAN Stations

fetchSCAN(site.code, year, report = "SCAN", req = NULL)

Arguments

site.code

a vector of site codes

year

a vector of years

report

report name, single value only

req

list of SCAN request parameters, for backwards-compatibility only

Value

a data.frame object; NULL on bad request.

Details

See the fetchSCAN tutorial for details. These functions require the httr and rvest libraries.

References

https://www.wcc.nrcs.usda.gov/index.html

Author

D.E. Beaudette

Examples


# \donttest{
if(requireNamespace("curl") &
    curl::has_internet()) {

    # get data: new interface
    x <- fetchSCAN(site.code=c(356, 2072), year=c(2015, 2016))
    str(x)

    # get sensor metadata
    m <- SCAN_sensor_metadata(site.code=c(356, 2072))

    # get site metadata
    m <- SCAN_site_metadata(site.code=c(356, 2072))
}
#> 19336 records (0.83 Mb transferred)
#> List of 10
#>  $ metadata:'data.frame':	2 obs. of  12 variables:
#>   ..$ Name         : chr [1:2] "Blue Lakes" "Eros Data Center"
#>   ..$ Site         : num [1:2] 356 2072
#>   ..$ State        : chr [1:2] "California" "South Dakota"
#>   ..$ Network      : chr [1:2] "SNOTEL" "SCAN"
#>   ..$ County       : chr [1:2] "Alpine" "Minnehaha"
#>   ..$ Elevation_ft : num [1:2] 8067 1602
#>   ..$ Latitude     : num [1:2] 38.6 43.7
#>   ..$ Longitude    : num [1:2] -119.9 -96.6
#>   ..$ HUC          : chr [1:2] "180400120101" "101702031402"
#>   ..$ climstanm    : chr [1:2] NA "Eros Data Center"
#>   ..$ upedonid     : chr [1:2] NA "S2003SD099001"
#>   ..$ pedlabsampnum: chr [1:2] NA "03N0688"
#>  $ SMS     :'data.frame':	5752 obs. of  7 variables:
#>   ..$ Site      : int [1:5752] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:5752], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:5752] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:5752] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:5752] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ depth     : num [1:5752] 5 5 5 5 5 5 5 5 5 5 ...
#>   ..$ sensor.id : Factor w/ 5 levels "SMS.I_2","SMS.I_8",..: 1 1 1 1 1 1 1 1 1 1 ...
#>  $ STO     :'data.frame':	5843 obs. of  7 variables:
#>   ..$ Site      : int [1:5843] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:5843], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:5843] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:5843] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:5843] 1.4 1.4 1.3 1.3 1.3 1.3 1.3 1.4 1.4 1.4 ...
#>   ..$ depth     : num [1:5843] 5 5 5 5 5 5 5 5 5 5 ...
#>   ..$ sensor.id : Factor w/ 5 levels "STO.I_2","STO.I_8",..: 1 1 1 1 1 1 1 1 1 1 ...
#>  $ TAVG    :'data.frame':	1460 obs. of  7 variables:
#>   ..$ Site      : int [1:1460] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:1460], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:1460] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:1460] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:1460] -13.1 -6.3 -4.6 -1.5 0.5 2 3 2.2 1.2 2.2 ...
#>   ..$ depth     : num [1:1460] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "TAVG.D": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ TMIN    :'data.frame':	1460 obs. of  7 variables:
#>   ..$ Site      : int [1:1460] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:1460], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:1460] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:1460] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:1460] -17 -10.9 -12.5 -8.1 -5.2 -4.2 -2.2 -3.8 -5.1 -1.4 ...
#>   ..$ depth     : num [1:1460] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "TMIN.D": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ TMAX    :'data.frame':	1460 obs. of  7 variables:
#>   ..$ Site      : int [1:1460] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:1460], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:1460] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:1460] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:1460] -8.9 2 7 9.2 8.1 11.3 13.8 12.5 10.3 6.4 ...
#>   ..$ depth     : num [1:1460] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "TMAX.D": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ PRCP    :'data.frame':	581 obs. of  7 variables:
#>   ..$ Site      : int [1:581] 2072 2072 2072 2072 2072 2072 2072 2072 2072 2072 ...
#>   ..$ Date      : Date[1:581], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:581] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:581] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:581] 0 0 0 0.08 0 0 0 0 0.23 0 ...
#>   ..$ depth     : num [1:581] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "PRCP.D": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ PREC    :'data.frame':	1316 obs. of  7 variables:
#>   ..$ Site      : int [1:1316] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:1316], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:1316] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:1316] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:1316] 9.1 9.1 9.1 9.1 9.1 9.1 9.1 9.1 9.1 9.1 ...
#>   ..$ depth     : num [1:1316] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "PREC.I": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ SNWD    :'data.frame':	731 obs. of  7 variables:
#>   ..$ Site      : int [1:731] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:731], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:731] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:731] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : int [1:731] 21 20 20 20 19 18 18 18 17 17 ...
#>   ..$ depth     : num [1:731] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "SNWD.I": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ WTEQ    :'data.frame':	731 obs. of  7 variables:
#>   ..$ Site      : int [1:731] 356 356 356 356 356 356 356 356 356 356 ...
#>   ..$ Date      : Date[1:731], format: "2015-01-01" "2015-01-02" ...
#>   ..$ water_year: num [1:731] 2015 2015 2015 2015 2015 ...
#>   ..$ water_day : int [1:731] 93 94 95 96 97 98 99 100 101 102 ...
#>   ..$ value     : num [1:731] 6.1 6.1 6.1 6.1 6.1 6.1 6.1 6.1 6.1 6.1 ...
#>   ..$ depth     : num [1:731] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ sensor.id : Factor w/ 1 level "WTEQ.I": 1 1 1 1 1 1 1 1 1 1 ...
# }