Learn R Programming

stplanr (version 0.2.8)

line_to_points: Convert a SpatialLinesDataFrame to points The number of points will be double the number of lines with line2points. A closely related function, line2pointsn returns all the points that were line vertices. The points corresponding with a given line, i, will be (2*i):((2*i)+1).

Description

Convert a SpatialLinesDataFrame to points The number of points will be double the number of lines with line2points. A closely related function, line2pointsn returns all the points that were line vertices. The points corresponding with a given line, i, will be (2*i):((2*i)+1).

Usage

line_to_points(l, ids = rep(1:nrow(l), each = 2))

line2pointsn(l)

Arguments

l

A SpatialLinesDataFrame

ids

Vector of ids (by default 1:nrow(l))

Examples

Run this code
# NOT RUN {
l <- routes_fast[2:4, ]
lpoints <- line_to_points(l)
lpoints2 <- line2pointsn(l)
plot(lpoints, pch = lpoints$id, cex = lpoints$id)
points(lpoints2, add = TRUE)
line_to_points(routes_fast_sf[2:4, ])
# }

Run the code above in your browser using DataLab