View source: R/sp_segment_lines.R
sp_segment_lines | R Documentation |
sp_segment_lines
has been pulled from another package which can be
found here,
sp_segment_lines(sp, length, features = FALSE)
sp |
Spatial line object. |
length |
Length for the split segments. This is in the units of
|
features |
Should the function be applied to all features in |
SpatialLinesDataFrame with one id
variable.
Jason Taylor, David Blodgett, and Stuart K. Grange
https://github.com/jmt2080ad/polylineSplitter
# Make a line, this is in Switzerland so am using the local, metric projection
# system
sp_lines <- dplyr::tribble(
~latitude, ~longitude,
47.381114, 8.5769906,
47.3839327, 8.5831275,
47.3884799, 8.5849729,
47.3902377, 8.5856166,
47.3910512, 8.5865822,
47.3930994, 8.5912171,
47.3938402, 8.5924187,
47.3951621, 8.5935345,
47.3975152, 8.5952726,
47.3993162, 8.5954228,
47.4057356, 8.598856
) %>%
sp_from_data_frame(type = "lines") %>%
sp_transform(projection_swiss())
# Check length
sp_length(sp_lines)
# Into 100 metre sections
sp_lines_split <- sp_segment_lines(sp_lines, length = 100)
# Check lengths
sp_length(sp_lines_split, features = TRUE)
sp_length(sp_lines_split, features = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.