Learn R Programming

lawn (version 0.6.0)

lawn_pt2line_distance: Minimum distance between a point and a lineString

Description

Returns the minimum distance between a data-Point and a data-LineString, being the distance from a line the minimum distance between the point and any segment of the LineString.

Usage

lawn_pt2line_distance(
  point,
  line,
  units = "kilometers",
  mercator = FALSE,
  lint = FALSE
)

Arguments

point

(data-Feature<(data-Point)>) feature or geometry

units

(character) Can be degrees, radians, miles, or kilometers (default)

mercator

(logical) if distance should be on Mercator or WGS84 projection. Default: FALSE

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

distance between point and line (numeric)

See Also

Other measurements: lawn_along(), 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_square()

Examples

Run this code
# NOT RUN {
pt <- lawn_point("[0, 0]")
ln <- lawn_linestring("[[1, 1],[-1, 1]]")

lawn_pt2line_distance(pt, ln)
lawn_pt2line_distance(pt, ln, mercator = TRUE)

lawn_pt2line_distance(pt, ln, 'miles')
lawn_pt2line_distance(pt, ln, 'radians')
lawn_pt2line_distance(pt, ln, 'degrees')
lawn_pt2line_distance(pt, ln, mercator = TRUE)
# }

Run the code above in your browser using DataLab