The rgdal package contains bindings from R to the GDAL (Geospatial Data Abstraction Library) as well as the PROJ library. It is a dependency for numerous spatial statistics packages. Note that the binaries on the rgdal homepage are outdated — the most up-to-date version of the rgdal package can be found on CRAN.
Unsurprisingly, rgdal requires both the GDAL and PROJ framework to run. Both frameworks for Mac OS X are kindly maintained by William Kyngesburye and can be found here:
I recommend installing GDAL Complete as it contains both required frameworks in a neat little package.
At the time of writing, there are two versions of GDAL Complete:
- GDAL 1.7 Complete
- GDAL 1.6 Complete
Both should work for rgdal but note that currently, the stable Mac OS X version of Quantum GIS (QGIS 1.4) only runs with GDAL 1.6, so if you need to use QGIS as well, I would recommend installing GDAL 1.6. If you’ve installed GDAL 1.7, then you’ll have to use the developer’s release of QGIS.
(May 19, 2011 update: Install GDAL 1.8 Complete as it works for both standard and developer’s release of QGIS)
Next, assuming you installed GDAL above with the default paths, you’ll need to install the R package from source (get package source here) with modified arguments either with
install.packages() or through the terminal:
R CMD INSTALL --configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config --with-proj-include=/Library/Frameworks/PROJ.framework/unix/include --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib' rgdal_0.6-33.tar.gz
If you’re getting this error:
Error: package ‘rgdal’ is not installed for ‘arch=i386′
when trying to load the rgdal package, it is because your version of rgdal was not compiled for the 32-bit version of R. You’ll need to run the 64-bit version of R (R64.app on Macs).
You may also need to update the base version of the sp package as well as any other dependencies.