lawn_midpoint: Get a point midway between two points

Description Usage Arguments Value See Also Examples

View source: R/midpoint.R

Description

Takes two data-Point's and returns a point midway between them

Usage

1
lawn_midpoint(pt1, pt2, lint = FALSE)

Arguments

pt1

First data-Feature<(data-Point)>

pt2

Second data-Feature<(data-Point)>

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)> midway between pt1 and pt2

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_point_on_feature(), lawn_pt2line_distance(), lawn_square()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pt1 <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [144.834823, -37.771257]
  }
}'
pt2 <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [145.14244, -37.830937]
  }
}'
lawn_midpoint(pt1, pt2)
## Not run: 
lawn_midpoint(pt1, pt2) %>% view
lawn_featurecollection(list(
  lawn_point(jsonlite::fromJSON(pt1)$geometry$coordinates),
  lawn_point(jsonlite::fromJSON(pt2)$geometry$coordinates),
  structure(lawn_midpoint(pt1, pt2), class = "point")
)) %>% view

## End(Not run)

lawn documentation built on Jan. 6, 2021, 5:07 p.m.