Installing rgdal on Mac OS X

******Roger Bivand has kindly just emailed me to say:

“Your 2 November blog about rgdal on OSX is very misleading. The CRAN rgdal page: says all you need to know unless you need extra drivers, or already have PROJ.4 and GDAL installed. Just do:


installs rgdal with all its external dependencies satisfied. It is kindly provided by Prof. Brian Ripley, and is presently running up-to-date GDAL.”******

This may offer a straightforward solution. I would be interested to hear how people get on.

After running a spatial data analysis with R session today, it became apparent that there are one or two teething problems installing the important rgdal package on Mac OS X operating systems. The usual install.packages(“rgdal”) won’t work. My colleague Jon Reades did some digging around to find this solution. I have tested it and it seems to work fine.

[Note that you’ll need to be comfortable with the Terminal. If you’re not, then find someone who is.]

1. Download the GDAL OS X install from kyngchaos
(Looks like the basic page [for updates after 1.7 if you’re reading this ages from now] is
– Install as per usual OS X install system
– Fire up the Terminal, then pico (or vi[m]) the .bash_login file
– Modify the PATH environment so that it reads:
export PATH=”/Library/Frameworks/GDAL.framework/Programs:$PATH”
[This is what enables the subsequent steps to find gdal-config]

2. Download and install proj4 from source
– Download source code version proj-4.7.0.tar.gz
– Fire up the Terminal
> cd ~/Downloads/
> tar -xzvf proj-4.7.0.tar.gz
> cd proj-4.7.0
> ./configure
> make && make test
> sudo make install
[ should install to /usr/local/lib by default]

3. Download and install rgdal from source
– Fire up the Terminal
> cd ~/Downloads/
> sudo R CMD INSTALL –configure-args=’–with-proj-include=/usr/local/lib’ rgdal_0.6-28.tar.gz

After all of this mucking about I was able to say:

> require(sp)
> require(rgdal)

And get a message indicating that GDAL was loaded successfully.

He also posted his solution on the Computational Mathematics Blog. If there is a better way I would be interested in hearing about it for future classes.