ring_area: geojson area function

View source: R/ring_area.R

ring_areaR Documentation

geojson area function

Description

geojson area function

Usage

ring_area(x)

Arguments

x

A list of coordinates. See examples for its form

Details

ported from geojson-aera JS library at https://github.com/mapbox/geojson-area

Calculate the approximate area of the polygon were it projected onto the earth. Note that this area will be positive if ring is oriented clockwise, otherwise it will be negative.

Reference: Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409

Value

single integer - The approximate signed geodesic area of the polygon in square meters. Positive if ring is oriented clockwise, otherwise it will be negative.

Examples

x <- '{
 "type":"Polygon",
 "coordinates":[
   [[100.0,0.0],[100.0,1.0],[101.0,1.0],[101.0,0.0],[100.0,0.0]]
 ]
}'
x <- jsonlite::fromJSON(x, FALSE)
ring_area(x = x$coordinates[[1]])
ring_area(x = rev(x$coordinates[[1]]))

ropenscilabs/geojsonrewind documentation built on May 18, 2022, 7:38 p.m.