Installing rgdal on Mac OS X

November 2, 2010

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

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.

To leave a comment for the author, please follow the link and comment on their blog: Spatial Analysis » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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...

Tags: , , , , , , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)