Install rgeos on OSX

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:

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.
  3. 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:

    and you should see the following:
  4. And your done.

7 thoughts on “Install rgeos on OSX

  • 2016-02-22 at 15:13
    Permalink

    This is very useful. Thank you!

    Reply
  • 2016-04-08 at 20:47
    Permalink

    THIS IS AWESOME!
    Thank you very much!

    Reply
  • 2016-07-15 at 15:11
    Permalink

    Thank you so very much for the suggestions, but it didn’t work for me. This is what I get

    #—- begin output —-
    * installing to library ‘/opt/local/Library/Frameworks/R.framework/Versions/3.3/Resources/library’
    * installing *source* package ‘rgeos’ …
    ** package ‘rgeos’ successfully unpacked and MD5 sums checked
    configure: CC: /usr/bin/clang
    configure: CXX: /usr/bin/clang++
    configure: rgeos: 0.3-19
    checking for /usr/bin/svnversion… yes
    configure: svn revision: 524
    checking for geos-config… no
    no
    configure: error: geos-config not found or not executable.
    ERROR: configuration failed for package ‘rgeos’
    * removing ‘/opt/local/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgeos’

    #—- end output —-

    which is pretty much the same error I get when using install.packages(“rgeos”). Any suggestions?

    Thanks once more

    Reply
    • 2016-07-15 at 18:18
      Permalink

      You need to have geos installed before you try to add the R package. Install it from brew and you will be ok. The configuration software is looking for geos-config in your $PATH and cannot find it.

      Reply
      • 2016-07-16 at 11:10
        Permalink

        Works like a charm! Thank you very very much

        Reply
  • 2017-02-02 at 09:49
    Permalink

    When I do step 3, Terminal tells me

    ‘-bash: R: command not found’

    What does this mean?

    Reply
    • 2017-02-14 at 15:05
      Permalink

      This means that you do not have R installed on your machine. You should be able to open the Terminal and type R and get the R prompt.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *