Install rgeos on OSX

A short description of the post.

Rodney Dyer https://dyerlab.org (Center for Environmental Studies)https://ces.vcu.edu
2015-03-31

There seems to be some nefarious conspiracy against packaging spatial R packages on the mac platform. Don’t quite understand it but it sucks. Here is how to install the rgeos package.

If you try the normal way, you get the following error:

install.packages("rgeos")
package ‘rgeos’ is available as a source package but not as a binary
Warning in install.packages : package ‘rgeos’ is not available (as a binary package for R version 3.1.3)

which is not very helpful. So here is a quick way to do that I use when I need to upgrade it or put it on a new machine.

  1. If you do not have the developers tools from Apple, download them and install through the normal AppStore mechanisms. You will need to compile stuff from raw code for this to work.
  2. Download and install the GDAL Complete package from KyngChaos. At the time of writing, it was version 1.11 (39.0 MB). If you are using Mavericks or later, you’ll have to probably change your security settings (System Preferences -> Security -> General) to “Allow apps downloaded from ‘anywhere’ to be installed. If everything works nicely (which I’ve never seen actually work), you should be able to do the following to install. Unfortunately, it always barfs on me.
    install.packages(“rgeos”, repos=“http://R-Forge.R-project.org”, type=“source”) trying URL ‘http://R-Forge.R-project.org/src/contrib/rgeos_0.3-9.tar.gz’ Content type ‘application/x-gzip’ length 238246 bytes (232 KB) opened URL ================================================== downloaded 232 KB
The downloaded source packages are in ‘/private/var/folders/06/jmbn_ny94rs1nw19xclvdzqc0000gn/T/Rtmp9VCkBI/downloaded_packages’ Warning message: In install.packages(“rgeos”, repos = “http://R-Forge.R-project.org”, : installation of package ‘rgeos’ had non-zero exit status
  1. This means that you need to actually compile the results. Download the latest sources from r-forge (use the *.tar.gz version). Open the terminal and:
    cd ~/Downloads
    R CMD INSTALL
    
and you should see the following:

<pre class="lang:default decode:true ">R CMD INSTALL rgeos_0.3-9.tar.gz --configure-args="--with-geos-config=/Library/Frameworks/GEOS.framework/unix/bin/geos-config"

Citation

For attribution, please cite this work as

Dyer (2015, March 31). The Dyer Laboratory: Install rgeos on OSX. Retrieved from https://dyerlab.github.io/DLabWebsite/posts/2015-03-31-install-rgeos-on-osx/

BibTeX citation

@misc{dyer2015install,
  author = {Dyer, Rodney},
  title = {The Dyer Laboratory: Install rgeos on OSX},
  url = {https://dyerlab.github.io/DLabWebsite/posts/2015-03-31-install-rgeos-on-osx/},
  year = {2015}
}