USGS - science for a changing world

Application - Part 1, find sites

As stated in the Challenge description, site information has been provided via ScienceBase. For the purposes of this exercise, let’s assume your cooperator gave you the link to the ScienceBase item that contained the site information. Using functions taught earlier in sbtools lessons, create a vector of the ScienceBase site numbers. In addition, use functions in dataRetrieval to gather relevant location data about each site (e.g. HUC ids).

Get sites

First, authenticate your ScienceBase session using authenticate_sb(). Now, use sbtools functions to read the appropriate file from the SB item created by your cooperator into R as a data frame. Try it on your own before looking at the answer below. Don’t hesitate to go back to the sbtools download data lesson for a refresher. Hint: the item id is the last element of the URL.

Create a vector of just site numbers to use for subsequent functions.

Get relevant site metadata

In anticipation of downloading precipitation data through the Geo Data Portal, we need to determine which regions to use since it does not operate based on NWIS sites. GDP can use 8-digit hydrologic unit codes (HUCs), which can be determined for each site number using readNWISsite. Use readNWISsite to get a vector of 8-digit HUCs. Try it on your own before looking at the answer below.

Lindsay R. Carr