Compiling RGDAL on OSX – Why do you hate me?

Every time I upgrade in any significant way, two R libraries seem to raise their ugly heads and scream like a spoiled child— rgdal and rgeos .  Why do these two have to be SOOOO much of a pain?  Why can’t we have a auto build of a binary with all the options in it for OSX?  Who knows?  I always feel like I get the fuzzy end of the lollipop with these two.  Here is my latest approach for getting them going.

First you have to make sure you have the latest GDAL libraries.  I used to get mine from Kyngchaos, just download the framework, install it, and then do some kind of long R CMD INSTALL  dance, which seems to no longer work for me.  I also tried installing from Ripley’s repository and found that (a) It was a version older than the one I already had on my machine, and (b) you can’t install from that repository , there is a malformed header and the install.packages()  function just barfs.

Time to try something new.  I typically stay away from the various installer frameworks out there on OSX to keep everything in Frameworks.  But this time, I used MacPorts.  You can find the latest version here.  Here is how I got it to help me out.

  1. Downloaded the version for my OS, I’m currently on 10.10 and installed it.
  2. In the terminal, I updated it sudo port -v selfupdate
  3. I then used it to install gdal as a unix library (rather than as a framework so it won’t be located in /Library/Frameworks) by sudo port install gdal.  There were a lot of dependencies for this one so it took a while.
  4. I then had R install rgdal as install.packages( rgdal, type="source")
  5. Worked like a charm.