sl.polygon.area: Compute Polygon Area on Sphere

View source: R/sl.polygon.area.R

sl.polygon.areaR Documentation

Compute Polygon Area on Sphere

Description

Compute the area of a polygon on a sphere.

Usage

sl.polygon.area(stamp.lon, stamp.lat, ref.lon = NA, ref.lat = NA)

Arguments

stamp.lon

a vector specifying the longitudes of the polygon vertices.

stamp.lat

a vector specifying the latitudes of the polygon vertices.

ref.lon

optionally, a scalar specifying the longitude of the reference point from which the polygon is decomposed into triangles. If not specified, the longitude of the barycenter of the vertices will be used.

ref.lat

optionally, a scalar specifying the latitude of the reference point from which the polygon is decomposed into triangles. If not specified, the latitude of the barycenter of the vertices will be used.

small

a logical value indicating whether or not to use sl.smalltriag.area. If FALSE (default), sl.triag.area will be used, which should be preferred for relatively large polygons (spanning more than a degree or so).

absval

a logical value indicating whether or not to return an absolute value (consistent with the usual definition of an 'area'; default). If set to FALSE, the sign of the result depends on the direction of rotation of the polygon: counterclockwise gives a positive result, and clockwise gives a negative result.

Details

First the polygon is decomposed into triangles from a reference point. The latter can be specified by the correspoding arguments; otherwise, the barycenter of the polygon vertices will be used. Second the area of each triangle is computed using sl.triag.area or sl.smalltriag.area (depending on the argument small) and multiplied by the triangle's direction of rotation using sl.checkposition. Third the results are summed up.

Value

A scalar giving the area of the poygon (on a unit sphere). If absval=TRUE, the return value is always positive (or zero) as one should expect; otherwise, a positive (negative) return value indicates that the direction of rotation of the polygon is counterclockwise (clockwise).

Author(s)

Helge Goessling

See Also

sl.triag.area, sl.smalltriag.area

Examples

sl.polygon.area(stamp.lon=c(0,1,1,0),stamp.lat=c(0,0,1,1))
## Should return:
## [1] 0.0003046097

helgegoessling/spheRlab documentation built on March 8, 2024, 7:54 p.m.