Learn R Programming

lawn (version 0.6.0)

lawn_line_distance: Measure a linestring

Description

Takes a data-LineString and measures its length in the specified units. Uses turf/length internally as lineDistance was deprecated

Usage

lawn_line_distance(line, units, lint = FALSE)

Arguments

units

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

Length of the input 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_midpoint(), lawn_point_on_feature(), lawn_pt2line_distance(), lawn_square()

Examples

Run this code
# NOT RUN {
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_line_distance(line, 'kilometers')
lawn_line_distance(line, 'miles')
lawn_line_distance(line, 'radians')
lawn_line_distance(line, 'degrees')
# }

Run the code above in your browser using DataLab