How to install rNOMADS on Linux

January 24, 2014

(This article was first published on Bovine Aerospace » R, and kindly contributed to R-bloggers)

About 6 months ago, I wrote a package for the R programming language called rNOMADS.  It interfaces with the National Oceanic and Atmospheric Association’s Operational Archive and Distribution System (NOMADS), comprising everything from global weather forecast models, to high resolution regional models, to wave and sea ice models.  rNOMADS uses R to download requested data from the NOMADS servers and uses an external program called wgrib2 to read the data files.  This allows R users to make some spectacular pictures (see below) but I also hope that it will lead to greater availability of these valuable resources to data analysts all over the world.  Already, rNOMADS is being used in an online sailboat racing game and to get data for predicting solar and wind energy output.  However, rNOMADS can be a bit of a challenge to install.  Below the picture, I’ll outline an installation I recently did on an Ubuntu computer.  Other Linux should be similar.  To my knowledge, Windows users will have to use Cygwin.  I am not sure about Mac.

World temperature at 2 m above ground, generated using rNOMADS.

World temperature at 2 m above ground, generated using rNOMADS.

Step 1

The first step is to make sure R is configured correctly. You can skip the reinstallation (step 2) if need be, but I recommend getting r-base-dev anyway for all the libraries it has.

apt-get install r-base-dev
apt-get build-dep r-base

Step 2

Then, I build R from the source. You can skip this method if you’ve already done this.

You can download the latest version (as of March 2014) here.
Navigate to the file and type:

tar -xvf R-3.0.3.tar.gz
cd R-3.0.3
make install

Step 3

Now we get dependencies for specific packages that rNOMADS requires.

apt-get install libxml2-dev
apt-get install libcurl4-openssl-dev
apt-get install libboost-dev

Step 4

Now, we install wgrib2 and wgrib and add them to our path.
Download wgrib2 here.
Download wgrib here.

tar -xvf wgrib2.tgz
cd grib2/
mv wgrib2/ /usr/local

mkdir wgrib
mv wgrib.tar wgrib
cd wgrib
tar -xvf wgrib.tar
mkdir /usr/local/wgrib
mv * /usr/local/wgrib

gedit /etc/environment

add “/usr/local/wgrib2″ and “/usr/local/wgrib” to the end of the PATH variable, then close /etc/environment and close the superuser terminal.

source /etc/environment

Step 5

Now we install rNOMADS and another package called GEOmap so that we can build and test the example vignette.


Now we are in the R interpreter, as root. Type:


Step 6

If everything went well, you now have rNOMADS! Test rNOMADS (and learn how it works) by building the example vignette. First, download the source here and navigate to the saved file. Then, type:

R CMD Sweave rNOMADS_examples.Rnw
pdflatex rNOMADS_examples.tex

This should create a PDF file called “rNOMADS_examples.pdf” with code and images. It should look similar to this one.

To leave a comment for the author, please follow the link and comment on his blog: Bovine Aerospace » R. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.