USGS - science for a changing world

Application - Part 2, download data

In this section, we are going to use dataRetrieval and geoknife to get nitrogen, phosphorus, and precipitation data for the sites determined in the previous section.

We are walking through the workflow in very distinct chunks, but this will be put together as a single script at the end. The code that we used to get the site and 8-digit HUC numbers is available in the previous lesson or summarized in Part 5, the complete workflow.

Before downloading the data, make sure you identify the time period of interest. For this example, we are going to use water year 2016.

startDate <- "2015-10-01"
endDate <- "2016-09-30"

Get nutrient data

Now, use dataRetrieval functions to pull down data for nitrogen and phosphorus. You can choose your own parameter codes to define these nutrients using parameterCdFile or use the ones below.

pcodes_nitrogen <- c("00613", "00618", "00631")
pcodes_phosphorus <- c("00665")

Using your choice of readNWIS function, get a data frame with nitrogen data for all sites and a second data frame with phosphorus data for all sites. Revisit the lesson on downloading NWIS data to see what functions are available.

Get precip data

Now we need to download the precipitation data from GDP using geoknife. To do so, you will need a dataset and appropriate HUCs. Use the dataset titled “United States Stage IV Quantitative Precipitation Archive”. See ?webgeom for an example of how to format the geom for 8-digit HUCs.

Complete the steps to create and execute a geojob. Download the results of the process as a data.frame; this might take a few minutes (~ 10). See geoknife discovery and geoknife execute lessons for assistance.

Lindsay R. Carr