toSeg: Split polygons or lines to segments

Description Usage Arguments Value References Examples

View source: R/toSeg.R

Description

Split lines or polygons to separate segments.

Usage

1
toSeg(x)

Arguments

x

A SpatialLines* or a SpatialPolygons* object.

Value

A SpatialLines object where each segment is represented by a separate feature.

References

This function uses a modified version of code from the following 'r-sig-geo' post by Roger Bivand: https://stat.ethz.ch/pipermail/r-sig-geo/2013-April/017998.html

Examples

1
2
3
4
5
6
7
8
9
data(build)
seg = toSeg(build[1, ])
plot(seg, col = sample(rainbow(length(seg))))
raster::text(rgeos::gCentroid(seg, byid = TRUE), 1:length(seg))

# Other data structures
toSeg(geometry(build)) # SpatialPolygons
toSeg(sidewalk) # SpatialLinesDataFrame
toSeg(geometry(sidewalk)) # SpatialLinesDataFrame

michaeldorman/shadow documentation built on Sept. 30, 2018, 4:37 a.m.