geoprimsField-grade geospatial math

Polygon centroid and interior point

The center of mass of a polygon on the ellipsoid, a warning when it falls outside the shape, and a point guaranteed inside, as far from the edges as possible, for a label or a pin.

40.0015°

The centroid is at 40.0015°, -104.9987769°. A point inside, 35.22 m from the nearest edge, is at 40.0003173°, -104.9995869°.

  • The centroid falls outside the polygon, as it does for a C-shape or a ring. Use the interior point for a label or a pin.
Centroid longitude
Centroid inside
Interior point latitude
Interior point longitude
Interior point clearance
Area
Provenance
Computed by
geometry.shape.centroid 1.0.0, core 0.1.0
Model
Geodesic edges cut into 5 km pieces and mapped to a Lambert azimuthal equal-area plane on the authalic sphere of WGS 84, centered at the corners' mean (an exact equal-area map, Snyder 1987 ch. 24 and eq. 3-11 to 3-16); the centroid is the plane's area-weighted centroid, holes subtracted, mapped back. The interior point is the pole of inaccessibility on that plane (Agafonkin's polylabel, to 0.1% of the shape's narrow side), with its clearance measured as a geodesic distance
Accuracy
The centroid is exact for the equal-area plane, which is what area-weighting on a curved surface needs a choice of; for shapes of a few hundred kilometers it matches a local plane to well under 1 m. The interior point is within 0.1% of the shape's narrow side of the true pole of inaccessibility; for extreme slivers (thousands of times longer than wide) it is the best found within a fixed amount of work, always inside
Notes
1 shown with the answer
Cites
Snyder, J. P., U.S. Geological Survey, Map Projections: A Working Manual

Something look off?

Your values

Showing an example. Change anything.
KML, KMZ, GPX, GeoJSON, CSV, WKT, or WKB — or drop it on the box. Read on this device.
How we got thisFormula, worked example, sources, and proof

Model: Geodesic edges cut into 5 km pieces and mapped to a Lambert azimuthal equal-area plane on the authalic sphere of WGS 84, centered at the corners' mean (an exact equal-area map, Snyder 1987 ch. 24 and eq. 3-11 to 3-16); the centroid is the plane's area-weighted centroid, holes subtracted, mapped back. The interior point is the pole of inaccessibility on that plane (Agafonkin's polylabel, to 0.1% of the shape's narrow side), with its clearance measured as a geodesic distance

Accuracy: The centroid is exact for the equal-area plane, which is what area-weighting on a curved surface needs a choice of; for shapes of a few hundred kilometers it matches a local plane to well under 1 m. The interior point is within 0.1% of the shape's narrow side of the true pole of inaccessibility; for extreme slivers (thousands of times longer than wide) it is the best found within a fixed amount of work, always inside

When to use this: Use this to find the middle of an area — the centre of a parcel, a search zone, a coverage polygon, a district — when the answer has to sit correctly on the ellipsoid rather than being the average of the corner coordinates, which is wrong for anything but a small symmetric shape. Two points come back, and they are for different jobs: the centroid is the centre of mass, which is what a calculation wants, and the interior point is guaranteed to be inside and as far from the edges as it can be, which is what a label or a map pin wants.

Limitations: The centroid of a shape on a curved surface is not defined until you choose how to weight area, and this weights it on an equal-area map, which is the choice that makes the answer independent of how the shape is oriented. For a concave shape — a C, a horseshoe, a ring — the centre of mass falls outside the polygon, which is correct and not an error; the tool says so and hands back the interior point instead. The interior point is found to within 0.1% of the shape’s narrow side, so it is the best place for a pin rather than a uniquely defined coordinate, and for a sliver thousands of times longer than it is wide it is the best found within a fixed amount of work. Holes are subtracted; self-intersecting outlines should be repaired first.

Worked example: A C-shaped lot, whose centroid falls in the notch. Source: a C shape, whose centre of mass falls outside it: CENTROID_OUTSIDE is raised and the interior point returned. Checked against PROJ 9.3.0's ellipsoidal Lambert azimuthal equal-area with GEOS 3.11.4's planar centroid over twelve shapes, which agree with the tool to 23 mm and to 4.6e-9 of the area. It is golden test vector v010, and every build checks the tool still gives its answer within its tolerance.

You enter

Polygon
40, -105 40, -104.997 40.0006, -104.997 40.0006, -104.9994 40.0024, -104.9994 40.0024, -104.997 40.003, -104.997 40.003, -105

You get

Centroid latitude
40.0015°
Centroid longitude
-104.9987769°
Centroid inside
no
Interior point latitude
40.0003173°
Interior point longitude
-104.9995869°
Interior point clearance
35.22 m
Area
0.044373282 km²

Review: Not yet independently reviewed by a GIS professional.

Last verified: 2026-09-19, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.0, core 0.1.0. See this tool in the verification report.

Checked against: 24 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources