Installing and loading StreamCatTools
To install, currently you need to install from GitHub using devtools
library(devtools)
install_github('USEPA/StreamCatTools')
After installing load the library
Background
The StreamCatTools
package was designed to simplify the
use of StreamCat
data in R, leveraging the new API for
StreamCat.
StreamCat API
We can pull data into R from the StreamCat
API by simply passing a URL to extract from json. We have to
hard-wire parameters though and are limited in the number of records
returned through a GET
request.
res <- jsonlite::fromJSON("https://api.epa.gov/StreamCat/streams/metrics?name=fert&areaOfInterest=cat&comid=179")
res$items
#> fertws fertcat comid
#> 1 1.438 1.438 179
List API parameters
List StreamCat parameters: Get a list of available StreamCat values
for certain parameters using the sc_get_params
function via
the API
region_params <- sc_get_params(param='areaOfInterest')
name_params <- sc_get_params(param='metric_names')
print(paste0('region parameters are: ', paste(region_params,collapse = ', ')))
#> [1] "region parameters are: cat, catrp100, other, ws, wsrp100"
print(paste0('A selection of available StreamCat metrics include: ',paste(name_params[1:10],collapse = ', ')))
#> [1] "A selection of available StreamCat metrics include: agkffact, al2o3, bankfulldepth, bankfullwidth, bfi, canaldens, cao, cbnf, chem, clay"
We can also see what metrics are available for what areas of interest
and what years using the sc_get_params
function (which
returns a tibble of information about StreamCat metrics):
var_info <- sc_get_params(param='variable_info')
head(var_info)
#> # A tibble: 6 × 11
#> category metric aoi year short_description long_description units dsid
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Anthropogen… NABD_… Cat,… NA NABD Dam Density Density of geor… Coun… 33
#> 2 Anthropogen… NABD_… Cat,… NA NABD NID Reservo… Volume all rese… Cubi… 33
#> 3 Anthropogen… NABD_… Cat,… NA NABD Normal Rese… Volume all rese… Cubi… 33
#> 4 Natural Preci… Cat,… NA Surplus Precipit… This dataset re… Kilo… 75
#> 5 Natural Rckde… Cat,… NA Mean Bedrock Dep… Mean depth (cm)… Cent… 56
#> 6 Soils agkff… Cat,… NA Ag Soil Erodibil… Mean of STATSGO… Unit… 28
#> # ℹ 3 more variables: dataset <chr>, source_name <chr>, source_URL <chr>
We can look up the display name or names for a metric using the
sc_fullname
function via the API
metric='pcthbwet2011'
fullname <- sc_fullname(metric)
fullname
#> [1] "pcthbwet2011"
metric='pctdecid2019,fert'
fullname <- sc_fullname(metric)
fullname
#> [1] "pctdecid2019" "fert"
We can additionally get a data frame of state FIPS codes,
abbreviations and names, and the same information for counties as well
using sc_get_params
:
states <- sc_get_params(param='state')
head(states)
#> st_fips st_abbr st_name
#> 1 01 AL Alabama
#> 2 04 AZ Arizona
#> 3 05 AR Arkansas
#> 4 06 CA California
#> 5 08 CO Colorado
#> 6 09 CT Connecticut
counties <- sc_get_params(param='county')
head(counties)
#> fips state county_name
#> 1 01001 AL Autauga County
#> 2 01003 AL Baldwin County
#> 3 01005 AL Barbour County
#> 4 01007 AL Bibb County
#> 5 01009 AL Blount County
#> 6 01011 AL Bullock County
Get data for COMIDs
In this example we access several variables, for several areas of
interest, and for several COMIDs using the sc_get_data
function. Loads data into a tibble we can view.
df <- sc_get_data(metric='pcturbmd2006,damdens,tridens', aoi='rp100cat,cat,ws', comid='179,1337,1337420')
knitr::kable(df)
comid | tridensws | damdenscat | pcturbmd2006cat | tridenscat | pcturbmd2006ws | damdensws |
---|---|---|---|---|---|---|
179 | 0 | 0 | 0.00 | 0 | 0.00 | 0.0000 |
1337 | 0 | 0 | 0.07 | 0 | 0.07 | 0.0000 |
1337420 | 0 | 0 | 0.00 | 0 | 0.01 | 0.0329 |
Get data for county
In this example we access a couple variables at the watershed scale
for the area of interest of a county (Benton County in this case) using
the sc_get_data
function.
df <- sc_get_data(metric='pctwdwet2006', aoi='ws', county='41003')
knitr::kable(head(df))
comid | pctwdwet2006ws |
---|---|
23762961 | 1.11 |
23762985 | 0.84 |
23762915 | 1.14 |
23762959 | 1.14 |
23762967 | 1.10 |
23762761 | 1.72 |
Get all metrics for COMIDs or an Area of Interest
We can also get all StreamCat metrics for a set of COMIDs or an area of interest. Please do not request all metrics for conus in order not to overload requests to the server.
df <- sc_get_data(comid='179', aoi='cat', metric='all')
knitr::kable(head(df))
comid | pctburnarea1984cat | pctburnarea1985cat | pctburnarea1986cat | pctburnarea1987cat | pctmodsev1993cat | pcthighsev1993cat | pctincvegresp1993cat | pctnonprocmask1993cat | pctundsev1996cat | pctlowsev1996cat | pctburnarea1988cat | pctburnarea1989cat | pctburnarea1990cat | pctburnarea1991cat | pctburnarea1992cat | pctburnarea1993cat | pctburnarea1994cat | pctburnarea1995cat | pctburnarea1996cat | pctburnarea1997cat | pctburnarea1998cat | pctburnarea1999cat | pctburnarea2000cat | pctburnarea2001cat | pctburnarea2002cat | pctburnarea2003cat | pctburnarea2004cat | pctburnarea2005cat | pctburnarea2006cat | pctburnarea2007cat | pctburnarea2008cat | pctburnarea2009cat | pctburnarea2010cat | pctburnarea2011cat | pctburnarea2012cat | pctburnarea2013cat | pctburnarea2014cat | pctburnarea2015cat | pctburnarea2016cat | pctburnarea2017cat | pctburnarea2018cat | pctlowsev1993cat | pctmodsev1996cat | pcthighsev1996cat | pctincvegresp1996cat | pctnonprocmask1996cat | pctundsev1998cat | pctlowsev1998cat | pctmodsev1998cat | pcthighsev1998cat | pctincvegresp1998cat | pctnonprocmask1998cat | pctundsev2004cat | pctlowsev2004cat | pctmodsev2004cat | pcthighsev2004cat | pctincvegresp2004cat | pctnonprocmask2004cat | pctundsev2007cat | pctlowsev2007cat | pctmodsev2007cat | pcthighsev2007cat | pctincvegresp2007cat | pctnonprocmask2007cat | pctundsev2008cat | pctlowsev2008cat | pctmodsev2008cat | pcthighsev2008cat | pctincvegresp2008cat | pctnonprocmask2008cat | pctundsev2010cat | pctlowsev2010cat | pctmodsev2010cat | pcthighsev2010cat | pctincvegresp2010cat | pctnonprocmask2010cat | pctundsev2011cat | pctlowsev2011cat | pctmodsev2011cat | pcthighsev2011cat | pctincvegresp2011cat | pctnonprocmask2011cat | pctundsev2016cat | pctlowsev2016cat | pctundsev1984cat | pctlowsev1984cat | pctmodsev1984cat | pcthighsev1984cat | pctincvegresp1984cat | pctnonprocmask1984cat | septiccat | pctundsev1986cat | pctlowsev1986cat | pctmodsev1986cat | pcthighsev1986cat | pctincvegresp1986cat | pctnonprocmask1986cat | pctundsev1989cat | pctlowsev1989cat | pctmodsev1989cat | pcthighsev1989cat | pctincvegresp1989cat | pctnonprocmask1989cat | pctundsev1994cat | pctlowsev1994cat | pctmodsev1994cat | pcthighsev1994cat | pctincvegresp1994cat | pctnonprocmask1994cat | pctundsev1997cat | pctlowsev1997cat | pctmodsev1997cat | pcthighsev1997cat | pctincvegresp1997cat | pctnonprocmask1997cat | pctundsev2001cat | pctlowsev2001cat | pctmodsev2001cat | pcthighsev2001cat | pctincvegresp2001cat | pctnonprocmask2001cat | pctundsev2009cat | pctlowsev2009cat | pctmodsev2009cat | pcthighsev2009cat | pctincvegresp2009cat | pctnonprocmask2009cat | pctundsev2012cat | pctlowsev2012cat | pctmodsev2012cat | pcthighsev2012cat | pctincvegresp2012cat | pctnonprocmask2012cat | pctundsev2018cat | pctlowsev2018cat | pctmodsev2018cat | pcthighsev2018cat | pctincvegresp2018cat | pctnonprocmask2018cat | pctagslphigh2006cat | pctagslpmid2008cat | pctagslpmid2004cat | pctagslphigh2004cat | pctagslpmid2006cat | pctagslphigh2008cat | pctagslpmid2011cat | pctagslphigh2011cat | pctagdrainagecat | nsurpcat | nanicat | pctbl2008cat | pctconif2008cat | pctcrop2008cat | pctdecid2008cat | pctgrs2008cat | pcthay2008cat | pcthbwet2008cat | pctice2008cat | pctmxfst2008cat | pctow2008cat | pctshrb2008cat | pcturbhi2008cat | pcturblo2008cat | pcturbmd2008cat | pcturbop2008cat | pctwdwet2008cat | pctundsev2006cat | pctlowsev2006cat | pctmodsev2006cat | pcthighsev2006cat | pctincvegresp2006cat | pctnonprocmask2006cat | rockncat | pctundsev2015cat | pctlowsev2015cat | pctmodsev2015cat | pcthighsev2015cat | pctincvegresp2015cat | pctnonprocmask2015cat | wdrw_ldcat | pctagslpmid2001cat | pctagslphigh2001cat | pctimp2001cat | pctimp2004cat | pctimp2006cat | pctimp2008cat | pctimp2011cat | pctimp2013cat | pctimp2016cat | pctimp2019cat | pctbl2004cat | pctconif2004cat | pctcrop2004cat | pctdecid2004cat | pctgrs2004cat | pcthay2004cat | pcthbwet2004cat | pctice2004cat | pctmxfst2004cat | pctow2004cat | pctshrb2004cat | pcturbhi2004cat | pcturblo2004cat | pcturbmd2004cat | pcturbop2004cat | pctwdwet2004cat | pctbl2019cat | pctconif2019cat | pctcrop2019cat | pctdecid2019cat | pctgrs2019cat | pcthay2019cat | pcthbwet2019cat | pctice2019cat | pctmxfst2019cat | pctow2019cat | pctshrb2019cat | pcturbhi2019cat | pcturblo2019cat | pcturbmd2019cat | pcturbop2019cat | pctwdwet2019cat | wetindexcat | pctundsev1987cat | pctlowsev1987cat | pctmodsev1987cat | pcthighsev1987cat | pctincvegresp1987cat | pctnonprocmask1987cat | pctundsev1990cat | pctlowsev1990cat | pctmodsev1990cat | pcthighsev1990cat | pctincvegresp1990cat | pctnonprocmask1990cat | pctundsev1991cat | pctlowsev1991cat | pctmodsev1991cat | pcthighsev1991cat | pctincvegresp1991cat | pctnonprocmask1991cat | pctundsev1995cat | pctlowsev1995cat | pctmodsev1995cat | pcthighsev1995cat | pctincvegresp1995cat | pctnonprocmask1995cat | pctundsev1999cat | pctlowsev1999cat | pctmodsev1999cat | pcthighsev1999cat | pctincvegresp1999cat | pctnonprocmask1999cat | pctundsev2002cat | pctlowsev2002cat | pctmodsev2002cat | pcthighsev2002cat | pctincvegresp2002cat | pctnonprocmask2002cat | pctundsev2013cat | pctlowsev2013cat | pctmodsev2013cat | pcthighsev2013cat | pctincvegresp2013cat | pctnonprocmask2013cat | pctundsev2014cat | pctlowsev2014cat | pctundsev2003cat | pctlowsev2003cat | pctmodsev2003cat | pcthighsev2003cat | pctincvegresp2003cat | pctnonprocmask2003cat | pctundsev2005cat | pctlowsev2005cat | pctmodsev2005cat | pcthighsev2005cat | pctincvegresp2005cat | pctnonprocmask2005cat | pctmodsev2014cat | pcthighsev2014cat | pctincvegresp2014cat | pctnonprocmask2014cat | pctmodsev2016cat | pcthighsev2016cat | pctincvegresp2016cat | pctnonprocmask2016cat | pctundsev2017cat | pctlowsev2017cat | pctmodsev2017cat | pcthighsev2017cat | pctincvegresp2017cat | pctnonprocmask2017cat | waterinputcat | wwtpmajordenscat | wwtpminordenscat | wwtpalldenscat | pctimpslphigh2001cat | pctimpslphigh2004cat | pctimpslphigh2006cat | pctimpslphigh2008cat | pctimpslphigh2011cat | pctimpslphigh2013cat | pctimpslphigh2016cat | pctimpslphigh2019cat | pctimpslpmid2001cat | pctimpslpmid2004cat | pctimpslpmid2006cat | pctimpslpmid2008cat | pctimpslpmid2011cat | pctimpslpmid2013cat | pctimpslpmid2016cat | pctimpslpmid2019cat | pctundsev2000cat | pctlowsev2000cat | pctmodsev2000cat | pcthighsev2000cat | pctincvegresp2000cat | pctnonprocmask2000cat | sio2cat | compstrgthcat | pctfire2001cat | agkffactcat | pctwdwet2011cat | coalminedenscat | elevcat | pcturbop2006cat | pcturbhi2001cat | hydcat | no32008cat | pctalluvcoastcat | fe2o3cat | pcturblo2011cat | cbnfcat | pctconif2006cat | pctgrs2001cat | pctfire2008cat | pctsallakecat | pctcoastcrscat | ncat | pctfire2003cat | pctglactilloamcat | pctfire2010cat | omcat | pctwatercat | pctow2011cat | pctice2011cat | pctwdwet2001cat | tmean2008cat | pctfire2000cat | pctcrop2001cat | pctextruvolcat | pcturbmd2011cat | pctfire2006cat | pctow2001cat | pcthbwet2001cat | na2ocat | pctglactilcrscat | tmean2009cat | damdenscat | pctdecid2011cat | sedcat | chemcat | manurecat | pctow2006cat | pctbl2001cat | sn2008cat | pctnonagintrodmanagvegcat | pcthydriccat | pctfire2005cat | pctconif2011cat | pctcarbresidcat | tmean8110cat | caocat | pctbl2011cat | kffactcat | pctglaclakecrscat | pctmxfst2011cat | k2ocat | pctice2006cat | pcteolfinecat | pcturbhi2006cat | precip8110cat | pcthay2006cat | pctsiliciccat | pctwdwet2006cat | pctfire2007cat | rdcrscat | nabd_denscat | pctice2001cat | damnidstorcat | precip2009cat | pcturbmd2006cat | tridenscat | pctglactilclaycat | wtdepcat | pestic1997cat | pcteolcrscat | pctmxfst2001cat | permcat | tempcat | popden2010cat | pcturbhi2011cat | al2o3cat | pcturblo2001cat | bficat | pctmxfst2006cat | conncat | pcthay2011cat | tmax8110cat | inorgnwetdep2008cat | nabd_nrmstorcat | huden2010cat | scat | p2o5cat | pctshrb2006cat | damnrmstorcat | nh42008cat | mgocat | pctgrs2011cat | pctalkintruvolcat | pctglaclakefinecat | pcturblo2006cat | pctshrb2011cat | canaldenscat | pcturbmd2001cat | habtcat | nabd_nidstorcat | pctbl2006cat | fertcat | npdesdenscat | tmin8110cat | pcthay2001cat | minedenscat | pctconif2001cat | superfunddenscat | pcturbop2011cat | pctfire2002cat | pcthbwet2011cat | rdcrsslpwtdcat | pctdecid2006cat | pctshrb2001cat | precip2008cat | sandcat | pctfire2009cat | claycat | pcturbop2001cat | pctdecid2001cat | pctcrop2006cat | pctnoncarbresidcat | runoffcat | pctgrs2006cat | pctcolluvsedcat | rckdepcat | hydrlcondcat | pcthbwet2006cat | rddenscat | pctcrop2011cat | pctconif2016cat | pctfire2004cat | pctcrop2016cat | pctdecid2016cat | pctgrs2016cat | pcthay2016cat | pcthbwet2016cat | pctice2016cat | pctmxfst2016cat | pctow2016cat | pctshrb2016cat | pcturbhi2016cat | pcturblo2016cat | pcturbmd2016cat | pcturbop2016cat | pctwdwet2016cat | sw_fluxcat | pctundsev1985cat | pctlowsev1985cat | pctmodsev1985cat | pcthighsev1985cat | pctincvegresp1985cat | pctnonprocmask1985cat | pctundsev1992cat | pctlowsev1992cat | pctmodsev1992cat | pcthighsev1992cat | pctincvegresp1992cat | pctnonprocmask1992cat | pctundsev1988cat | pctlowsev1988cat | pctmodsev1988cat | pcthighsev1988cat | pctbl2013cat | pctconif2013cat | pctcrop2013cat | pctdecid2013cat | pctgrs2013cat | pcthay2013cat | pcthbwet2013cat | pctice2013cat | pctmxfst2013cat | pctow2013cat | pctshrb2013cat | pcturbhi2013cat | pcturblo2013cat | pcturbmd2013cat | pcturbop2013cat | pctwdwet2013cat | pctbl2016cat | pctincvegresp1988cat | pctnonprocmask1988cat | pctundsev1993cat | pctfrstloss2001cat | pctfrstloss2002cat | pctfrstloss2003cat | pctfrstloss2004cat | pctfrstloss2005cat | pctfrstloss2006cat | pctfrstloss2007cat | pctfrstloss2008cat | pctfrstloss2009cat | pctfrstloss2010cat | pctfrstloss2011cat | pctfrstloss2012cat | pctfrstloss2013cat | precip9120cat | tmax9120cat | tmean9120cat | tmin9120cat | pctagslpmid2013cat | pctagslphigh2013cat | pctagslpmid2016cat | pctagslphigh2016cat | pctagslpmid2019cat | pctagslphigh2019cat |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
179 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1.117 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.17 | 3.17 | 0 | 3.17 | 0 | 3.17 | 0 | 0 | 2102.561 | 1675.837 | 0 | 4.89 | 1.52 | 3.87 | 0.05 | 1.09 | 1.04 | 0 | 49.06 | 0.05 | 0.91 | 0 | 0 | 0 | 0 | 37.52 | 0 | 0 | 0 | 0 | 0 | 0 | 88.2995 | 0 | 0 | 0 | 0 | 0 | 0 | 0.4413 | 3.17 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4.89 | 1.52 | 3.85 | 0.13 | 1.09 | 1.09 | 0 | 49.04 | 0.13 | 0.89 | 0 | 0 | 0 | 0 | 37.39 | 0 | 4.91 | 1.54 | 3.7 | 0.35 | 1.09 | 0.71 | 0 | 49.54 | 0 | 0.25 | 0 | 0 | 0 | 0 | 37.9 | 878.2494 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1.34e-05 | 0 | 0 | 0 | NA | NA | NA | NA | NA | NA | NA | NA | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 64.3313 | 169.6366 | 0 | NA | 37.57 | 0 | 196.1233 | 0 | 0 | 0.998 | 6.3799 | 0 | 5.5091 | 0 | 0.0506 | 4.89 | 0.23 | 0 | 0 | 0 | 8e-04 | 0 | 100 | 0 | 12.28701 | 0 | 0.1 | 0 | 36.89 | 5.032428 | 0 | 1.52 | 0 | 0 | 0 | 0 | 1.95 | 1.0772 | 0 | 4.852966 | 0 | 3.8 | 0.9958425 | 0.972 | 0 | 0.08 | 0 | 342.1452 | 0 | 0 | 0 | 4.89 | 0 | 4.885117 | 7.9453 | 0 | NA | 0 | 49.16 | 1.0557 | 0 | 0 | 0 | 1059.078 | 1.09 | 0 | 37.29 | 0 | 0 | 0 | 0 | 0 | 1108.386 | 0 | 0 | 0 | 49.21784 | 40.52718 | 0 | 48.76 | 5.130848 | 0.9983122 | 8.874548 | 0 | 10.276 | 0 | 52 | 49.01 | 1 | 1.09 | 10.59572 | 2.4653 | 0 | 5.910425 | 0.0161 | 0.1545 | 1.01 | 0 | 1.3213 | 2.2883 | 0.13 | 0 | 0 | 0 | 0.81 | 0 | 0 | 0.997 | 0 | 0 | 1.438 | 0 | -0.8263614 | 1.22 | 0 | 4.89 | 0 | 0 | 0 | 0.94 | 0 | 3.8 | 0.73 | 1254.539 | 22.33772 | 0 | 14.35371 | 0 | 3.82 | 1.52 | 0 | 646 | 0.08 | 0 | 134.9983 | 0.2044 | 1.24 | 0.5276 | 1.52 | 4.91 | 0 | 1.54 | 3.87 | 0.05 | 1.09 | 0.71 | 0 | 49.67 | 0 | 0.25 | 0 | 0 | 0 | 0 | 37.9 | 133875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4.89 | 1.52 | 3.77 | 0.05 | 1.09 | 0.76 | 0 | 49.7 | 0 | 0.38 | 0 | 0 | 0 | 0 | 37.85 | 0 | 0 | 0 | 0 | 0.71 | 0 | 0 | 0.35 | 0.03 | 0 | 0 | 0 | 0 | 0 | 0 | 0.23 | 0 | 1152.678 | 10.56534 | 5.015274 | -0.5362276 | 3.17 | 0 | 3.17 | 0 | 3.17 | 0 |
Get NLCD data
In this example we access National Land Cover Dataset (NLCD) data for
2001, just at the catchment level for several COMIDs using the
sc_nlcd
function. Loads data into a tibble we can view.
comid | pcturbhi2001cat | pctgrs2001cat | pctwdwet2001cat | pctcrop2001cat | pctow2001cat | pcthbwet2001cat | pctbl2001cat | pctice2001cat | pctmxfst2001cat | pcturblo2001cat | pcturbmd2001cat | pcthay2001cat | pctconif2001cat | pctshrb2001cat | pcturbop2001cat | pctdecid2001cat |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
179 | 0 | 0.23 | 36.89 | 1.52 | 0.0 | 1.95 | 0.00 | 0 | 48.76 | 0.00 | 0 | 1.22 | 4.89 | 0.73 | 0.00 | 3.82 |
1337 | 0 | 1.60 | 20.75 | 0.00 | 0.1 | 0.56 | 0.28 | 0 | 51.55 | 0.24 | 0 | 2.83 | 5.65 | 0.66 | 3.98 | 11.79 |
1337420 | 0 | 0.87 | 0.95 | 0.00 | 0.0 | 1.64 | 0.00 | 0 | 3.77 | 0.40 | 0 | 0.11 | 4.06 | 3.38 | 1.77 | 83.06 |
We can also pass a couple years for a different area of interest for another region like a county.
comid | pctbl2019ws | pctconif2019ws | pctcrop2019ws | pctdecid2019ws | pctgrs2019ws | pcthay2019ws | pcthbwet2019ws | pctice2019ws | pctmxfst2019ws | pctow2019ws | pctshrb2019ws | pcturbhi2019ws | pcturblo2019ws | pcturbmd2019ws | pcturbop2019ws | pctwdwet2019ws | pctice2006ws | pctmxfst2006ws | pctcrop2006ws | pcthay2006ws | pcturbop2006ws | pctbl2006ws | pctconif2006ws | pctwdwet2006ws | pctgrs2006ws | pcturbhi2006ws | pcturbmd2006ws | pctshrb2006ws | pcthbwet2006ws | pctdecid2006ws | pcturblo2006ws | pctow2006ws |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
23762961 | 0.01 | 36.68 | 4.65 | 1.03 | 1.51 | 33.28 | 3.44 | 0 | 7.32 | 0.08 | 3.99 | 0.10 | 1.69 | 0.30 | 3.46 | 2.46 | 0 | 5.85 | 3.00 | 35.58 | 3.44 | 0.01 | 26.93 | 1.11 | 5.74 | 0.09 | 0.23 | 10.78 | 4.79 | 0.66 | 1.67 | 0.11 |
23762985 | 0.00 | 51.52 | 1.58 | 1.03 | 2.21 | 20.06 | 0.84 | 0 | 9.14 | 0.04 | 6.06 | 0.05 | 1.46 | 0.24 | 4.60 | 1.18 | 0 | 7.16 | 1.05 | 21.16 | 4.62 | 0.01 | 37.51 | 0.84 | 8.44 | 0.04 | 0.19 | 15.78 | 1.22 | 0.51 | 1.44 | 0.04 |
23762915 | 0.01 | 55.83 | 0.01 | 1.58 | 2.74 | 6.60 | 0.40 | 0 | 18.61 | 0.05 | 7.45 | 0.01 | 0.60 | 0.14 | 4.65 | 1.33 | 0 | 19.10 | 0.01 | 6.87 | 4.63 | 0.01 | 49.77 | 1.14 | 4.71 | 0.01 | 0.12 | 11.15 | 0.58 | 1.27 | 0.58 | 0.05 |
23762959 | 0.01 | 36.29 | 4.66 | 1.02 | 1.50 | 33.72 | 3.51 | 0 | 7.24 | 0.09 | 3.95 | 0.10 | 1.68 | 0.30 | 3.43 | 2.51 | 0 | 5.79 | 3.02 | 36.01 | 3.41 | 0.01 | 26.64 | 1.14 | 5.68 | 0.09 | 0.23 | 10.66 | 4.88 | 0.66 | 1.66 | 0.12 |
23762967 | 0.01 | 38.81 | 3.54 | 1.04 | 1.60 | 31.71 | 3.49 | 0 | 7.53 | 0.09 | 4.30 | 0.09 | 1.65 | 0.29 | 3.40 | 2.47 | 0 | 5.98 | 2.42 | 33.49 | 3.39 | 0.01 | 28.48 | 1.10 | 6.20 | 0.08 | 0.23 | 11.36 | 4.86 | 0.64 | 1.64 | 0.13 |
23762761 | 0.00 | 57.44 | 0.40 | 1.90 | 3.08 | 2.45 | 0.27 | 0 | 20.77 | 0.01 | 6.65 | 0.00 | 0.31 | 0.07 | 4.89 | 1.76 | 0 | 19.15 | 0.05 | 2.84 | 4.91 | 0.00 | 38.13 | 1.72 | 7.95 | 0.00 | 0.04 | 23.53 | 0.31 | 1.06 | 0.29 | 0.01 |
Get COMIDs
In this example we use the sc_get_comid
function to find
COMIDs for USGS stream gages we load into R. We use a .csv file with
coordinate columns and a known coordinate reference system.
gages = readr::read_csv(system.file("extdata","Gages_flowdata.csv", package = "StreamCatTools"),show_col_types = FALSE)
# we'll just grab a few variables to keep things simple
gages <- gages[,c('SOURCE_FEA','STATION_NM','LON_SITE','LAT_SITE')]
gages_coms <- sc_get_comid(gages, xcoord='LON_SITE', ycoord='LAT_SITE', crsys=4269)
# Add the COMID we found back to gages data frame
gages$COMID <- strsplit(gages_coms, ",")[[1]]
df <- sc_get_data(metric='huden2010', aoi='ws', comid=gages_coms)
df$COMID <- as.character(df$comid)
gages <- dplyr::left_join(gages, df, by='COMID')
knitr::kable(head(gages))
Get data for a hydroregion
In this example we access a couple watershed-only metrics for a
particular NHDPlus hydroregion using the sc_get_data
function.
df <- sc_get_data(metric='pctwdwet2006', aoi='ws', region='Region17')
knitr::kable(head(df))
comid | pctwdwet2006ws |
---|---|
22988611 | 0.99 |
24114311 | 0.29 |
24114309 | 0.27 |
24116239 | 0.42 |
22988639 | 0.00 |
22988711 | 0.02 |