When working with spatial data, one is rarely interested in working with only one source of data. This tutorial will introduce a set of tools for linking vector data with other data sources. It begins by introducing how to link spatial vector data with non-spatial data in table format, then turns to the problem of linking multiple sources of spatial data through spatial joins and intersects.
This tutorial uses the sp
, rgdal
, and raster
libraries from the RGIS1
tutorial. If you have not yet installed those, please revisit that tutorial for directions. In addition, this tutorial will also make use of the rgeos
and plyr
libraries, installation of which is discussed in part0_setup
.
Most geometric operations – like creating buffers, creating geometric intersections, unions of polygons, etc. – are executed using the rgeos
library. Whenever you’re thinking about a geometric operation, rgeos
is the first place to look.
On Windows
install.packages(c("rgeos", "plyr"))
is usually all you need!On Macs
Installation of the rgeos
library on Macs can be a little tricky – as of September 2015, install.packages("rgeos")
will not work on macs (though hopefully this will change soon?). In the meantime, most people find the following directions works:
RGIS1
.install.packages("rgeos", type = "source", configure.args = "--with-geos-config=/Library/Frameworks/GEOS.framework/Versions/Current/unix/bin/geos-config")
library(rgeos)
. If it works, you’re done!plyr
by install.packages("plyr")
To test your installation, just type library(rgeos)
and library(plyr)
. If it loads, you’re set!
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.