lawn_along: Get a point at a distance along a line

View source: R/along.R

lawn_alongR Documentation

Get a point at a distance along a line

Description

Takes a data-LineString and returns a data-Point at a specified distance along the line.

Usage

lawn_along(line, distance, units, lint = FALSE)

Arguments

line

An input data-LineString.

distance

Distance along the line.

units

Units for the distance argument. Can be degrees, radians, miles, or kilometers.

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-Point distance units along the line.

See Also

Other measurements: lawn_area(), lawn_bbox_polygon(), lawn_bbox(), lawn_bearing(), lawn_center_of_mass(), lawn_center(), lawn_centroid(), lawn_destination(), lawn_distance(), lawn_envelope(), lawn_extent(), lawn_line_distance(), lawn_midpoint(), lawn_point_on_feature(), lawn_pt2line_distance(), lawn_square()

Examples

pts <- '[
   [-21.964416, 64.148203],
   [-21.956176, 64.141316],
   [-21.93901, 64.135924],
   [-21.927337, 64.136673]
]'
lawn_along(lawn_linestring(pts), 1, 'miles')

line <- '{
"type": "Feature",
"properties": {},
"geometry": {
  "type": "LineString",
  "coordinates": [
    [-77.031669, 38.878605],
    [-77.029609, 38.881946],
    [-77.020339, 38.884084],
    [-77.025661, 38.885821],
    [-77.021884, 38.889563],
    [-77.019824, 38.892368]
    ]
 }
}'
lawn_along(line, distance = 1, units = 'miles')
## Not run: 
lawn_along(lawn_linestring(pts), 1, 'miles') %>% view
res <- lawn_along(lawn_linestring(pts), 1, 'miles')
lawn_featurecollection(list(res, lawn_linestring(pts))) %>% view

## End(Not run)

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