\chapter{Install Package From Source} \label{app:installfromsource} \SweaveOpts{keep.source=TRUE, pdf=TRUE} <>= options(digits=3, show.signif.stars=FALSE, width=53) options(width=50) rm(list=ls()) @ Most of the R packages used in this book are available on CRAN as a pre-compiled binary files for Linux, Mac OS X, Solaris, and Windows. But not all R packages have a binary version for your hardware. In particular the {\bf rgdal} package that provides bindings to Frank Warmerdam's Geospatial Data Abstraction Library (GDAL) and acess to projection/transformation operations from the PROJ.4 library and used throughout this book does not have a binary file for Mac OS X. If you use a Mac, follow the steps below to compile from the source and make the {\bf rgdal} functions available in your workspace. \begin{enumerate} \item Download and install 2.14 version of R from CRAN. \item Download the source package for {\bf rgdal} from \url{cran.r-project.org/web/packages/rgdal/index.html} as a tarball and save it on your Desktop. \item Open R and install the packages {\bf sp}, {\bf Hmisc}, and {\bf R2HTML}. \item Using your Finder, Go \verb@>@ Applications \verb@>@ Utilities \verb@>@ Terminal.app. \item In the terminal window, type \verb@cd Desktop@. \item Copy and paste the following into the terminal window. \begin{verbatim} R CMD INSTALL rgdal_0.7-8.tar.gz --configure-args='--with-gdal-config=/Library/ Frameworks/GDAL.framework/Versions/Current/ Programs/gdal-config --with-proj-include=/Library/Frameworks/ PROJ.framework/Versions/Current/Headers --with-proj-lib=/Library/Frameworks/PROJ.framework/ Versions/Current/unix/lib' \end{verbatim} Make sure the {\bf rgdal\_0.7-8.tar.gz} matches the tarball name as saved on your desktop in Step 2. \item In R, type \verb@require(rgdal)@. \end{enumerate} If successful, it should say: \begin{verbatim} Loading required package: sp Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.8.1, released 2011/07/09 Path to GDAL shared files: /Library/Frameworks/GDAL.framework/Versions/1.8/ Resources/gdal Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470] Path to PROJ.4 shared files: (autodetected) \end{verbatim} Alternatively you can try installing the binary from the CRAN extras repository by typing <>= setRepositories(ind=1:2) install.packages('rgdal') require(rgdal) @