lawn_center_of_mass: Center of mass

View source: R/centerofmass.R

lawn_center_of_massR Documentation

Center of mass

Description

Takes a data-Feature or a data-FeatureCollection and returns its center of mass using formula https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon

Usage

lawn_center_of_mass(x, lint = FALSE)

Arguments

x

a data-Feature or data-FeatureCollection

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)>

See Also

Other measurements: lawn_along(), lawn_area(), lawn_bbox_polygon(), lawn_bbox(), lawn_bearing(), lawn_center(), lawn_centroid(), lawn_destination(), lawn_distance(), lawn_envelope(), lawn_extent(), lawn_line_distance(), lawn_midpoint(), lawn_point_on_feature(), lawn_pt2line_distance(), lawn_square()

Examples

x <- '{
 "type": "Feature",
 "properties": {},
 "geometry": {
     "type": "Polygon",
     "coordinates": [[
       [-112.072391,46.586591],
       [-112.072391,46.61761],
       [-112.028102,46.61761],
       [-112.028102,46.586591],
       [-112.072391,46.586591]
     ]]
   }
}'
lawn_center_of_mass(x)

lawn_center_of_mass(lawn_data$polygons_average)

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