Learn R Programming

lawn (version 0.1.7)

lawn_line_distance: Measure a linestring

Description

Takes a data-LineString and measures its length in the specified units.

Usage

lawn_line_distance(line, units, lint = FALSE)

Arguments

line
Line to measure, a data-LineString
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_bearing, lawn_center, lawn_centroid, lawn_destination, lawn_distance, lawn_envelope, lawn_extent, lawn_midpoint, lawn_point_on_surface, lawn_size, lawn_square

Examples

Run this code
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