Computes the centroid of a polygon as the arithmetic mean of its
outer-ring vertices. For non-convex shapes this point is not guaranteed
to lie inside the polygon, but it is a deterministic, dataset-stable
label position.
Returns undefined when the outer ring is missing or yields no usable
coordinates - the caller can use this signal to skip downstream work
rather than receive a [NaN, NaN] sentinel.
Parameters
polygon: Polygon
GeoJSON Polygon.
Returns [number,number]|undefined
Mean [lon, lat] of the outer ring, or undefined if the
ring is empty.
Computes the centroid of a polygon as the arithmetic mean of its outer-ring vertices. For non-convex shapes this point is not guaranteed to lie inside the polygon, but it is a deterministic, dataset-stable label position.
Returns
undefinedwhen the outer ring is missing or yields no usable coordinates - the caller can use this signal to skip downstream work rather than receive a[NaN, NaN]sentinel.