a5_bbox: Bounding box of polygons with great-circle edges

View source: R/regions.R

a5_bboxR Documentation

Bounding box of polygons with great-circle edges

Description

Returns, for each polygon feature, the longitude/latitude box that contains its edges as A5 draws them: great circles between consecutive vertices (see a5_polygon_to_cells()). Such an edge bows toward the pole, so the box can extend beyond the latitudes of the vertices, which a plain vertex bounding box would miss. A ring that winds around a pole extends the box to that pole across all longitudes.

Usage

a5_bbox(x)

Arguments

x

A polygon-like geometry. One of:

  • Any geometry handleable by wk::wk_handle() (e.g. wk::wkt(), wk::wkb(), wk::rct(), sf, sfc) containing one or more POLYGON / MULTIPOLYGON features.

  • A SpatVector of polygons (requires the terra package).

  • A two-column numeric matrix (cbind(lon, lat)) of vertices, interpreted as a single outer ring.

  • A data.frame with columns lon and lat, interpreted as a single outer ring.

Details

Longitudes are continuous: a box crossing the antimeridian has xmin between -180 and 180 and xmax above 180.

Value

A wk::rct() vector with one box per feature (one for matrix and data.frame input), in WGS 84 longitude and latitude. NA for a missing or empty geometry.

See Also

a5_polygon_to_cells()

Examples

# an edge along 60 degrees north bows toward the pole
poly <- wk::wkt("POLYGON ((-30 50, 30 50, 30 60, -30 60, -30 50))")
a5_bbox(poly)
wk::wk_bbox(poly)

a5R documentation built on Oct. 19, 2026, 5:08 p.m.