Skip to contents

Find the mid-point of lines

Usage

line_midpoint(l, tolerance = NULL)

Arguments

l

A spatial lines object

tolerance

The tolerance used to break lines at verteces. See lwgeom::st_linesubstring().

Examples

l <- routes_fast_sf[2:5, ]
plot(l$geometry, col = 2:5)
midpoints <- line_midpoint(l)
#> Warning: st_linesubstring does not follow a geodesic; you may want to use st_geod_segmentize first
#> Warning: st_linesubstring does not follow a geodesic; you may want to use st_geod_segmentize first
plot(midpoints, add = TRUE)
# compare with sf::st_point_on_surface:
midpoints2 <- sf::st_point_on_surface(l)
#> Warning: st_point_on_surface assumes attributes are constant over geometries
#> Warning: st_point_on_surface may not give correct results for longitude/latitude data
plot(midpoints2, add = TRUE, col = "red")
#> Warning: ignoring all but the first attribute