SpatialNetwork: a Class for Spatial Networks (lines and edges)

SpatialNetwork(sl, g, weight, weightfield, direction, zero)

Arguments

sl

object of one of (a sublasses of) SpatialLines, with links

g

object of class igraph; if missing, the graph is sorted out from the links

weight

weight for links (defaults to length of linestring)

weightfield

character; name of the attribute field of sl that will be used as weights

direction

numeric; if omitted, undirected graph, else integer vector indicating direction of a link: -1 for up-link, 0 for two-way, or 1 for down-link

zero

numeric; zero threshold passed on to zerodist

Value

object of class SpatialNetwork-class

Details

A class to store spatial networks, such as a road network.

Note

note

Slots

bbox

matrix, holding bounding box

proj4string

object of class CRS-class

lines

list

data

data.frame, holding attributes associated with lines

g

object of a subclass of igraph

weightfield

character; describing the weight field used

Examples

library(sp) # Lines, SpatialLines l0 = cbind(c(1, 2), c(0, 0)) l1 = cbind(c(0, 0, 0), c(0, 1, 2)) l2 = cbind(c(0, 0, 0), c(2, 3, 4)) l3 = cbind(c(0, 1, 2), c(2, 2, 3)) l4 = cbind(c(0, 1, 2), c(4, 4, 3)) l5 = cbind(c(2, 2), c(0, 3)) l6 = cbind(c(2, 3), c(3, 4)) LL = function(l, ID) Lines(list(Line(l)), ID) l = list(LL(l0, "e"), LL(l1, "a"), LL(l2, "b"), LL(l3, "c"), LL(l4, "d"), LL(l5, "f"), LL(l6, "g")) sl = SpatialLines(l) sln = SpatialNetwork(sl) plot(sln)
points(sln)
library(igraph) # E
#> #> Attaching package: ‘igraph’
#> The following objects are masked from ‘package:stats’: #> #> decompose, spectrum
#> The following object is masked from ‘package:base’: #> #> union
text(V(sln@g)$x, V(sln@g)$y, E(sln@g), pos = 4)
plot(sln@g)