lawn_point_on_line: Get closest point on linestring to reference point

View source: R/point_on_line.R

lawn_point_on_lineR Documentation

Get closest point on linestring to reference point

Description

Takes a line, a start data-Point, and a stop point and returns the line in between those points

Usage

lawn_point_on_line(line, point, lint = FALSE)

Arguments

line

data-Feature<(data-LineString)> to snap to

point

data-Feature<(data-Point)> to snap from

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-Feature<(data-Point)>

Examples

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]
    ]
  }
}'
pt <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [-77.037076, 38.884017]
  }
}'
lawn_point_on_line(line, pt)

# lint input objects
lawn_point_on_line(line, pt, TRUE)
## Not run: 
line %>% view
pt %>% view
lawn_point_on_line(line, pt) %>% view

## End(Not run)

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