GeoJSON centroids
Turn polygons into points. For each feature you get a centroid — area-weighted for polygons, or the mean of the vertices, or the centre of the bounding box — either as a new point geometry or as centroid_lng / centroid_lat properties on the original.
GeoJSON centroids
What this tool does
It computes one representative point per feature and keeps the properties attached, so a polygon layer becomes a point layer you can label, cluster, or join. Three methods are offered because "centre" means different things: the area-weighted centroid is the geometric centre of mass, the mean of vertices is dominated by wherever the outline has the most points, and the bounding-box centre ignores shape entirely.
The intent it closes: "I need a single coordinate for each of these shapes" — for a label, a marker, a distance calculation, or a spreadsheet column. The output keeps every original property, so the point layer is a drop-in replacement wherever the polygon layer was.
How this tool works
Per feature, per method.
1. Pick the geometry
Each feature is handled independently. A Polygon uses its exterior ring; a MultiPolygon uses the exterior ring of its first part; anything else — points, lines, collections — falls back to the mean of all its positions, which is the only meaningful answer for those types.
2. Compute the point
The area-weighted centroid uses the standard polygon-centroid formula (the shoelace sums over consecutive vertex pairs), which puts the point at the shape's centre of mass rather than in the middle of its vertex cloud. If the ring has zero area — a degenerate or unclosed outline — the calculation falls back to the vertex mean instead of returning nothing.
3. Emit the result
With point features, each feature's geometry is replaced by the centroid Point. With keep original geometry, the shape is untouched and only the properties change — which is what you want when the coordinates are for a label or a join key rather than a new layer. Coordinates are rounded to the decimals you choose.
Options
Method
Area-weighted is the right default for polygons: it is the geometric centre and it does not move when you add vertices along an edge. Mean of vertices is the honest answer for point and line layers, and it is what you want for a cluster of points. Bounding-box centre is stable and cheap, and it is the only one guaranteed to sit in the middle of the extent — useful for setting a map view, less useful as a label anchor.
Output / properties
Replacing the geometry gives you a point layer; keeping it gives you the same layer annotated. Add lng/lat properties writes centroid_lng and centroid_lat, which survive a later conversion to CSV — the usual reason to want them.
Example
Input:
{
"type": "Feature",
"properties": { "name": "Block" },
"geometry": { "type": "Polygon",
"coordinates": [[[0,0],[4,0],[4,2],[0,2],[0,0]]] }
}
Output (area-weighted, point features):
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"properties": { "name": "Block", "centroid_lng": 2, "centroid_lat": 1 },
"geometry": { "type": "Point", "coordinates": [2, 1] } }
]
}
For this rectangle all three methods agree. They diverge as soon as the shape is irregular: an L-shaped polygon's area centroid can fall outside the polygon, while its bbox centre certainly will.
Tips & common pitfalls
- A centroid can fall outside its polygon. That is mathematically correct for concave shapes, crescents and rings — it is not a bug. If you need a point guaranteed to be inside, you want a "pole of inaccessibility" algorithm, which this tool does not implement.
- The calculation is planar, not geodesic. Longitude and latitude are treated as plane coordinates. At country scale the error is small; for a shape spanning many degrees of latitude the point drifts slightly poleward of the true geodesic centre.
- MultiPolygons use their first part. For an archipelago that means the centroid of one island, not the whole group. Use mean of vertices or explode the parts first if that matters.
- Antimeridian-crossing shapes give odd answers. A polygon spanning ±180° averages to somewhere near longitude 0. Split such geometries before computing centroids.
FAQ
Which method should I use for labels?
Area-weighted, for polygons. It sits at the centre of mass, which reads as the natural place for a name — except on strongly concave shapes, where you may need to nudge labels by hand.
Why is my centroid not in the middle of the extent?
Because the area centroid weights by area, not by extent. A shape with a long thin tail has its centroid in the bulky part. The bounding-box option gives you the extent centre if that is what you want.
Does it keep my properties?
Yes, every property is copied to the output feature, plus the optional centroid_lng and centroid_lat.
What happens to features with null geometry?
They are skipped and counted in the status line, rather than producing a feature with no coordinates.