forked from nickeubank/gis_in_r
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGIS2_MergingSpatialData_part0_setup.Rmd
More file actions
68 lines (50 loc) · 3 KB
/
RGIS2_MergingSpatialData_part0_setup.Rmd
File metadata and controls
68 lines (50 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: "Merging Spatial Data"
output:
html_document:
toc: true
toc_depth: 4
theme: spacelab
mathjax: default
fig_width: 6
fig_height: 6
---
```{r knitr_init, echo=FALSE, cache=FALSE, message=FALSE}
library(knitr)
library(rmdformats)
## Global options
options(max.print="75")
opts_chunk$set(echo=TRUE,
cache=TRUE,
prompt=FALSE,
tidy=TRUE,
comment=NA,
message=FALSE,
warning=FALSE)
opts_knit$set(width=75)
library(rgdal)
library(sp)
library(rgeos)
library(dplyr)
```
***
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.
## 1. Installation Instructions
**On Windows**
* 1. `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:
* 1. Make sure you have downloaded and installed the [GDAL Complete](http://www.kyngchaos.com/files/software/frameworks/GDAL_Complete-1.11.dmg) library from `RGIS1`.
* 2. Run the following command:
```{r, eval=FALSE}
install.packages("rgeos", type = "source", configure.args ="--with-geos-config=/Library/Frameworks/GEOS.framework/Versions/Current/unix/bin/geos-config")
```
* 3. Test the installation by typing `library(rgeos)`. If it works, you're done!
* 4. If the library fails to load, try the directions on [this site](http://dyerlab.bio.vcu.edu/2015/03/31/install-rgeos-on-osx/)
* 5. Install `plyr` by `install.packages("plyr")`
## 2. Test Installation
To test your installation, just type `library(rgeos)` and `library(plyr)`. If it loads, you're set!
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.