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$itemsList API parameters
List StreamCat parameters: Get a list of available StreamCat values
for certain parameters using the sc_get_params function via
the API
library(StreamCatTools)
region_params <- sc_get_params(param='aoi')
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: "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 × 13
#> 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 Soils agkff… Cat,… NA Ag Soil Erodibil… Mean of STATSGO… Unit… 28
#> 6 Natural al2o3… Cat,… NA Mean Lithologica… Mean % of litho… Perc… 13
#> # ℹ 5 more variables: dataset <chr>, source_name <chr>, source_URL <chr>,
#> # ACTIVE <dbl>, DSNAME <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] "Herbaceous Wetland Percentage 2011"
metric='pctdecid2019,fert'
fullname <- sc_fullname(metric)
fullname
#> NULLWe 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)
#> NULL
counties <- sc_get_params(param='county')
head(counties)
#> fips state county_name
#> 752 01001 AL Autauga County
#> 713 01003 AL Baldwin County
#> 655 01005 AL Barbour County
#> 755 01007 AL Bibb County
#> 748 01009 AL Blount County
#> 656 01011 AL Bullock CountyFilter metric information by criteria
We can also filter metric names and information by the metric year(s), the indicator categories for metrics, the metric data set names, or the Areas of Interest the metrics are available for.
metrics <- sc_get_metric_names(category = c('Deposition','Climate'),aoi=c('Cat','Ws'))
head(metrics)
#> # A tibble: 6 × 9
#> Category Metric AOI Year Short_Name Metric_Description Units Source Dataset
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Climate bfi[A… Cat,… NA Base Flow… Base flow is the … Perc… USGS … Base F…
#> 2 Deposit… inorg… Cat,… 2008 Mean Annu… Annual gradient m… Kilo… NADP NADP
#> 3 Deposit… nh4[Y… Cat,… 2008 Mean annu… Annual gradient m… Kilo… NADP NADP
#> 4 Deposit… no3[Y… Cat,… 2008 Mean Annu… Annual gradient m… Kilo… NADP NADP
#> 5 Climate preci… Cat,… NA 30-year M… PRISM climate dat… Mill… PRISM PRISM
#> 6 Climate preci… Cat,… 1991… 30-year M… PRISM climate dat… Mill… PRISM PRISMGet 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 metric=‘all’ and aoi=‘conus’ in order not to overload requests to the server. Requesting metric=‘all’ for a state or multiple states or hydroregions will also take a long time to process.
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 | <<<<<<< HEADprecip_minus_evtcat | ======= >>>>>>> masterpctundsev1987cat | 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 | <<<<<<< HEADagkffactcat | =======agkffactcat | >>>>>>> masterpctwdwet2011cat | 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 | <<<<<<< HEADkffactcat | =======kffactcat | >>>>>>> masterpctglaclakecrscat | 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 | <<<<<<< HEADp_dep_2002cat | p_dep_2003cat | p_dep_2004cat | p_dep_2005cat | p_dep_2006cat | p_dep_2007cat | p_dep_2008cat | p_dep_2009cat | p_dep_2010cat | p_dep_2011cat | p_dep_2012cat | p_dep_2013cat | ======= >>>>>>> mastern_usgsww_1978cat | n_usgsww_1980cat | n_usgsww_1982cat | n_usgsww_1984cat | n_usgsww_1986cat | n_usgsww_1988cat | n_usgsww_1990cat | n_usgsww_1992cat | n_usgsww_1994cat | n_usgsww_1996cat | n_usgsww_1998cat | n_usgsww_2000cat | n_usgsww_2002cat | n_usgsww_2004cat | n_usgsww_2006cat | n_usgsww_2008cat | n_usgsww_2010cat | n_usgsww_2012cat | n_leg_1987cat | n_leg_1988cat | n_leg_1989cat | n_leg_1990cat | n_leg_1991cat | n_leg_1992cat | n_leg_1993cat | n_leg_1994cat | n_leg_1995cat | n_leg_1996cat | n_leg_1997cat | n_leg_1998cat | n_leg_1999cat | n_leg_2000cat | n_leg_2001cat | n_leg_2002cat | n_leg_2003cat | n_leg_2004cat | n_leg_2005cat | n_leg_2006cat | n_leg_2007cat | n_leg_2008cat | n_leg_2009cat | n_leg_2011cat | n_leg_2012cat | n_leg_2013cat | n_leg_2014cat | n_leg_2015cat | n_leg_2016cat | n_leg_2017cat | p_leg_1987cat | p_leg_1988cat | p_leg_1989cat | p_leg_1990cat | p_leg_1991cat | p_leg_1992cat | p_leg_1993cat | p_leg_1994cat | p_leg_1995cat | p_leg_1996cat | p_leg_1997cat | p_leg_1998cat | p_leg_1999cat | p_leg_2000cat | p_leg_2001cat | p_leg_2002cat | p_leg_2003cat | p_leg_2004cat | p_leg_2005cat | p_leg_2006cat | p_leg_2007cat | p_leg_2008cat | p_leg_2009cat | p_leg_2011cat | p_leg_2012cat | p_leg_2013cat | p_leg_2014cat | p_leg_2015cat | p_leg_2016cat | p_leg_2017cat | <<<<<<< HEADn_leg_2010cat | p_leg_2010cat | n_tin_1987cat | n_tin_1988cat | n_tin_1989cat | n_tin_1990cat | n_tin_1991cat | n_tin_1992cat | n_tin_1993cat | n_tin_1994cat | n_tin_1995cat | n_tin_1996cat | n_tin_1997cat | n_tin_1998cat | n_tin_1999cat | n_tin_2000cat | n_tin_2001cat | n_tin_2002cat | n_tin_2003cat | n_tin_2004cat | n_tin_2005cat | n_tin_2006cat | n_tin_2007cat | n_tin_2008cat | n_tin_2009cat | n_tin_2011cat | n_tin_2012cat | n_tin_2013cat | n_tin_2014cat | n_tin_2015cat | n_tin_2016cat | n_tin_2017cat | p_tin_1987cat | p_tin_1988cat | p_tin_1989cat | p_tin_1990cat | p_tin_1991cat | p_tin_1992cat | p_tin_1993cat | p_tin_1994cat | p_tin_1995cat | p_tin_1996cat | p_tin_1997cat | p_tin_1998cat | p_tin_1999cat | p_tin_2000cat | p_tin_2001cat | p_tin_2002cat | p_tin_2003cat | p_tin_2004cat | p_tin_2005cat | p_tin_2006cat | p_tin_2007cat | p_tin_2008cat | p_tin_2009cat | p_tin_2011cat | p_tin_2012cat | p_tin_2013cat | p_tin_2014cat | p_tin_2015cat | p_tin_2016cat | p_tin_2017cat | p_dep_1997cat | p_dep_1998cat | p_dep_1999cat | p_dep_2000cat | p_dep_2001cat | ======= >>>>>>> master
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | <<<<<<< HEAD46.1099 | ======= >>>>>>> master0 | 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 | <<<<<<< HEAD0.0026 | =======NA | >>>>>>> master37.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 | <<<<<<< HEAD0.2442 | =======NA | >>>>>>> master0 | 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 | <<<<<<< HEAD20.32574 | 18.50136 | 17.59088 | 18.2278 | 18.81752 | 18.56952 | 18.38229 | 17.69823 | 20.08625 | 18.56114 | 16.50694 | 17.57473 | ======= >>>>>>> master0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8016.374 | 8243.797 | 8542.023 | 8787.955 | 9007.697 | 9287.582 | 9438.607 | 9722.905 | 9996.046 | 10686.69 | 11330.88 | 12057.65 | 12981.15 | 13353.16 | 13811.05 | 14472.36 | 15211.29 | 16194.87 | 17547.07 | 19142.33 | 20611 | 22116.82 | 23411.37 | 24590.54 | 24772.69 | 25101.07 | 25575.9 | 26197.07 | 26964.96 | 27879.69 | 11011.91 | 11171.62 | 11383.85 | 11564.13 | 11738.34 | 11915.36 | 12000.95 | 12203.13 | 12392.89 | 12464.94 | 12537.05 | 12605.38 | 12721.52 | 12932.75 | 13172.6 | 13492.15 | 13836.86 | 14248.79 | 14793.05 | 15395.81 | 15956.26 | 16542.52 | 17068.58 | 17624.04 | 17758.03 | 17917.15 | 18101.46 | 18310.91 | 18545.61 | 18805.58 | <<<<<<< HEAD24530.75 | 17538.92 | 731.5523 | 696.5523 | 774.7137 | 2922.933 | 2476.309 | 2357.526 | 2377.684 | 2603.939 | 2371.844 | 2908.544 | 2667.832 | 3015.62 | 3115.135 | 2434.286 | 2419.809 | 3328.306 | 3014.946 | 2782.592 | 3300.603 | 3461.606 | 3283.332 | 3181.2 | 2763.434 | 1886.577 | 2083.627 | 1995.734 | 2137.391 | 2040.086 | 2140.836 | 2305.558 | 226.4224 | 238.475 | 292.1372 | 261.341 | 256.9639 | 262.13 | 169.9578 | 285.1908 | 271.4696 | 152.4241 | 151.6671 | 149.4479 | 198.2835 | 293.852 | 322.9758 | 403.1997 | 420.7817 | 480.4471 | 605.2297 | 656.1878 | 606.3166 | 638.3252 | 584.3335 | 155.8621 | 210.9557 | 228.3564 | 245.8559 | 263.2626 | 280.8009 | 298.3469 | 18.46541 | 21.6809 | 18.73153 | 19.38125 | 17.18284 | ======= >>>>>>> master
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
<<<<<<< HEAD
sc_get_nlcd function. Loads data into a tibble we can
view.
df <- sc_get_nlcd(year='2001', aoi='cat',
comid='179,1337,1337420')
knitr::kable(df)We can also pass a couple years for a different area of interest for another region like a county.
df <- sc_get_nlcd(year='2006, 2019', aoi='ws',
=======
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 |
Get data for CONUS
In this example we access a metric for conus using the
sc_get_data function - this is shown for demonstration but
not run as it takes a bit of time
df <- sc_get_data(metric='om', aoi='ws', conus='true')
knitr::kable(head(df))