polygon_area_cumulative: Compute cumulative polygon area and perimeter

View source: R/polygonarea.R

polygon_area_cumulativeR Documentation

Compute cumulative polygon area and perimeter

Description

Compute the area and perimeter of a polygon at each vertex, showing how the measurements accumulate as vertices are added.

Usage

polygon_area_cumulative(x, polyline = FALSE)

Arguments

x

A two-column matrix or data frame of coordinates (longitude, latitude) in decimal degrees defining polygon vertices, or a list with longitude and latitude components.

polyline

Logical. If FALSE (default), compute area and perimeter of a closed polygon. If TRUE, compute only the length of a polyline (area will be meaningless).

Details

This function is useful for understanding how polygon area accumulates and for debugging polygon vertex order issues.

Value

A data frame with columns:

  • lon: Longitude of vertex

  • lat: Latitude of vertex

  • area: Cumulative area in square meters up to this vertex

  • perimeter: Cumulative perimeter in meters up to this vertex

Examples

# Watch area accumulate as vertices are added
pts <- cbind(
  lon = c(0, -74, -43, 28),
  lat = c(52, 41, -23, -26)
)
polygon_area_cumulative(pts)

geographiclib documentation built on March 4, 2026, 9:07 a.m.