reorder_segments: Reorder line segments after intersection

Description Usage Arguments Details Value Examples

View source: R/shapefile_utils.R

Description

Reorder line segments after intersection

Usage

1
reorder_segments(src, parts)

Arguments

src

original line sf polyline object

parts

intersected sf polygon object

Details

Very briefly modificied from Spacedman's solution on StackExchange: https://gis.stackexchange.com/questions/295806/r-turn-off-automatic-ordering-of-linestrings-when-applying-sfst-intersection

Value

Re-ordered version of parts

Examples

1
2
3
4
5
6
7
8
9
#-- Read in shapefiles
str <- read_sf(system.file("extdata", "MehlandHill2010_stream.shp", package = "pbjr"))
tri <- read_sf(system.file("extdata", "720_triangles.shp", package = "pbjr"))

# Intersect
tri_stream <- st_intersection(tri, str)

#-- st_intersection can mess up segment order - it uses the triangle ID # to determine the order
tri_stream <- reorder_segments(str, tri_stream)

scantle/pbjr documentation built on Dec. 22, 2021, 10:19 p.m.