as.linnet.SpatialLines

0th

Percentile

Convert SpatialLines to Linear Network

Convert an object of class SpatialLines or SpatialLinesDataFrame (from package sp), representing a collection of polygonal lines, into an object of class linnet (from package spatstat), representing a network.

Keywords
manip, spatial
Usage
as.linnet.SpatialLines(X, …, fuse = TRUE)
  # S4 method for SpatialLines,linnet
coerce(from, to = "linnet", strict = TRUE)
  # S4 method for SpatialLinesDataFrame,linnet
coerce(from, to = "linnet",
    strict = TRUE)
Arguments
X, from

Object of class SpatialLines or SpatialLinesDataFrame to be converted.

to

output object of class “linnet”.

strict

logical flag. If TRUE, the returned object must be strictly from the target class.

Ignored.

fuse

Logical value indicating whether to join different curves which have a common vertex.

Details

This function converts an object of class SpatialLines or SpatialLinesDataFrame into an object of class linnet. It is not a method for the spatstat generic function as.linnet, but like other S4 coercion functions for sp classes to spatstat classes, it may be called directly as a function.

An object of class SpatialLines or SpatialLinesDataFrame (from package sp) represents a list of lists of the coordinates of lines, such as a list of all roads in a city. An object of class linnet in the spatstat package represents a linear network, such as a road network.

If fuse=FALSE, each “Line” object in X will be treated as if it were disconnected from the others. The result is a network that consists of many disconnected sub-networks, equivalent to the list of “Line” objects.

If fuse=TRUE (the default), the code will search for identical pairs of vertices occurring in different “Line” objects, and will treat them as identical vertices, effectively joining the two “Line” objects at this common vertex.

If X belongs to class SpatialLinesDataFrame, the associated columns of data in the auxiliary data frame slot(X, "data") will be copied to the output as the marks attached to the line segments of the network. See the Examples.

Value

An object of class linnet.

See Also

as.linnet

Aliases
  • as.linnet.SpatialLines
  • coerce,SpatialLines,linnet-method
  • coerce,SpatialLinesDataFrame,linnet-method
Examples
# NOT RUN {
  if(require(spatstat, quietly=TRUE)) {
   dname <- system.file("shapes", package="maptools")
   fname <- file.path(dname, "fylk-val.shp")
   fylk <- readShapeSpatial(fname)
   L <- as(fylk, "linnet")
   print(max(vertexdegree(L)))
   L0 <- as.linnet.SpatialLines(fylk, fuse=FALSE)
   print(max(vertexdegree(L0)))
   ## extract data associated with each network segment
   head(marks(as.psp(L)))
  }
# }
Documentation reproduced from package maptools, version 0.9-5, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.