splitLines: splitLines

Description Usage Arguments References Examples

Description

This function splits each line of an "sp" object of class SpatialLines into segments of a given length.

Usage

1
2
splitLines(spatial_line, split_length = 10, return.dataframe = FALSE,
  plot.results = FALSE)

Arguments

spatial_line

An "sp" object of class SpatialLines or SpatialLinesDataFrame.

split_length

The length of the segments to split the lines into, in units of the SpatialLines. Default 10.

return.dataframe

If TRUE, the functions returns a dataframe with IDs and coordinates, otherwise returns a SpatialLines object. Default FALSE.

plot.results

Visual representation of the results. If TRUE, the functions plots the original object in black and the vertex of the new segments in red. Default FALSE.

References

http://math.stackexchange.com/questions/175896/finding-a-point-along-a-line-a-certain-distance-away-from-another-point?newreg=468f66d7274f449b8ecf3fa4e63f41fe

http://tutorial.math.lamar.edu/Classes/CalcII/Vectors_Basics.aspx

Examples

1
2
3
4
5
6
7
library("sp", "sptools")
c1 = cbind(c(0,2,5,7), c(0,2,3,3))
l1 = Line(c1)
sl = list(Lines(list(l1), ID = 1))
SP = SpatialLines(sl)
plot(SP)
SPs = splitLines(SP, 0.4, plot.results = TRUE)

duccioa/sptools documentation built on May 3, 2019, 1:48 p.m.