SpatialNetwork-class: The SpatialNetwork class and constructor function

Description Usage Arguments Details Value Slots Note Author(s) Examples

Description

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

Usage

1
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

Details

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

Value

object of class SpatialNetwork-class

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

Note

note

Author(s)

Edzer Pebesma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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
text(V(sln@g)$x, V(sln@g)$y, E(sln@g), pos = 4)
plot(sln@g)

edzer/spnetwork documentation built on May 16, 2019, 12:10 a.m.