polygonAdjacency: Evaluate Spatial Adjacency of SpaitialPolygonsDataFrame...

Description Usage Arguments Details Value Author(s) Examples

View source: R/polygonAdjacency.R

Description

This function utilizes the 'spdep' and 'igraph' packages to evaluate several measures of spatial connectivity.

Usage

1
polygonAdjacency(x, v='MUSYM', ...)

Arguments

x

a SpatialPolygonsDataFrame object

v

name of the field in the attribute table to use when searching for 'common lines', see details

...

additional arguments passed to spdep::poly2nb

Details

Pending.

Value

A list object containing:

commonLines

An integer vector of feature IDs, that share a common boundary and attribute v.commonLines. Sometimes referred to as "common soil lines".

adjMat

A weighted adjacency matrix

Author(s)

D.E. Beaudette

Examples

 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
## Not run: 
library(spdep)
library(rgdal)
library(igraph)
library(sharpshootR)

# load some data
x <- readOGR(dsn='L:/CA630/FG_CA630_OFFICIAL.gdb', layer='ca630_a', stringsAsFactors=FALSE)

# remove NOTCOM, DA, and empty (non-NA) symbols
x <- x[which(! x$MUSYM 

# compute spatial adjacency summary
res <- polygonAdjacency(x, v='MUSYM')

# graphical check: slow for large number of features
plot(x)
plot(x[res$commonLines, ], col='red', add=TRUE)

# save to SHP
writeOGR(x[res$commonLines, ], dsn='.', 
layer='common-soil-lines', driver='ESRI Shapefile', 
overwrite_layer=TRUE)

# plot spatial adjacency information
par(mar=c(0,0,0,0))
plotSoilRelationGraph(res$adjMat, 
vertex.scaling.factor = 1)
plotSoilRelationGraph(res$adjMat, spanning.tree='max', 
edge.scaling.factor=0.1, vertex.scaling.factor=1)

## End(Not run)

sharpshootR documentation built on May 31, 2017, 2:05 a.m.