library(SpatialEpi)
#> Loading required package: sp
The next steps will install the open source geospatial libaries necessary for your computer to read in ESRI shapefiles. Fortunately you only have to do this once.
Install either Xcode (available for free in the App Store) or the Command Line Tools for Xcode. You’ll need to have a (free) Apple ID.
In your Mac menu bar go to System Preferences… -> Security & Privacy -> unlock the lock on the bottom left of panel -> select “Allow apps downloaded from”: Anywhere -> relock the lock
Open Terminal by going to a Finder window -> Applications -> Utilities -> Terminal. You open new tabs in Terminal by pressing command+T.
In Terminal
sudo xcodebuild -license
, scroll to the bottom and type agree
to agree to the licence.xcode-select --install
Install Macports as per the Quickstart instructions.
Install the gdal
and geos
geospatial libraries.
sudo port install gdal
sudo port install geos
Install the rgdal
package to interface the gdal
geospatial library with R
rgdal_X.Y-Z.tar.gz
where X,Y,Z
denote the version number.R CMD INSTALL ~/Downloads/rgdal_X.Y-Z.tar.gz
where X,Y,Z
are changed to match the name of the file you just downloadedInstall the rgeos
package to interface the geos
geospatial library with R
rgeos_X.Y-Z.tar.gz
where X,Y,Z
denote the version number.R CMD INSTALL ~/Downloads/rgeos_X.Y-Z.tar.gz
where X,Y,Z
are changed to match the name of the file you just downloadedinstall.packages("rgeos", repos="https://R-Forge.R-project.org", type="source")
I’m going to assume you know what you’re doing!
After installing the prerequisite packages, test that both the rgdal
and rgeos
packages are installed by running
library(rgdal)
library(rgeos)