
Since I don’t want to worry about cleaning up after myself and explicitly deleting the files I create, I’ll use the built-in functions tempfile() and tempdir() to place the files in R’s default temporary directory, and then download today’s data: # get the file url today = as.Date ( Sys.time ()) forecasturl = paste ( '', gsub ( '-', '', today ), '12_CentralCoast_hefs_csv_daily.zip', sep = '' ) # create a temporary directory td = tempdir () # create the placeholder file tf = tempfile ( tmpdir = td, fileext = ".zip" ) # download into the placeholder file download.file ( forecasturl, tf ) To download this file in R, we first have to create a placeholder file. Where xxxxxxxx is a datestring of format YYYYMMDD. zip files that can be accessed via the url The CNRFC data is accessible on the web, and the procedure is instructive for basic file management in R. I’m not going to go over downloading data using the waterData package as the documentation is fairly well developed in particular, I recommend the vignette hosted on CRAN. In my case, my sources are streamflow data provided by the USGS waterData package and ensemble forecasts developed by the California Nevada River Forecast Center ( CNRFC). The first step is to actually get the data. The data products would be used for reservoir management optimization and risk analysis.

I was asked to develop some simple tools to provide a workflow for pulling streamflow data, computing flow duration curves and fitting probability distributions to the data.

I was recently asked to develop some reservoir forecasting tools for the San Francisco Public Utilities Commission, partly in response to the severe drought conditions facing California. Downloading, extracting and reading files in R Feb 12, 2014
