lawn_line_slice_along: Slice a line given two points

View source: R/line_slice_along.R

lawn_line_slice_alongR Documentation

Slice a line given two points

Description

Takes a line, a specified distance along the line to a start Point, and a specified distance along the line to a stop point and returns a subsection of the line in-between those points. This can be useful for extracting only the part of a route between two distances.

Usage

lawn_line_slice_along(
  startDist,
  stopDist,
  line,
  units = "kilometers",
  lint = FALSE
)

Arguments

startDist

(numeric/integer) distance along the line to starting point

stopDist

(numeric/integer) distance along the line to ending point

line

Line to slice, a data-Feature<(data-LineString)>

units

can be degrees, radians, miles, or kilometers (default)

lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

A data-LineString, the sliced line

Examples

line <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [ 7.66845703125, 45.058001435398296 ],
      [ 9.20654296875, 45.460130637921004 ],
      [ 11.348876953125, 44.48866833139467 ],
      [ 12.1728515625, 45.43700828867389 ],
      [ 12.535400390625, 43.98491011404692 ],
      [ 12.425537109375, 41.86956082699455 ],
      [ 14.2437744140625, 40.83874913796459 ],
      [ 14.765625, 40.681679458715635 ]
    ]
  }
}'
lawn_line_slice_along(12.5, 25, line)
## Not run: 
line %>% view
lawn_line_slice_along(12.5, 25, line) %>% view

## End(Not run)

ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.