GeoJSON Centroid Calculator

Find the geographic center point of any GeoJSON geometry. Calculate centroids for polygons and feature collections.

Skip to the tool

The classic use for a polygon centroid is positioning a label on a country, state, or district. The classic problem is that the centroid of a crescent-shaped polygon lands outside the polygon — Florida's centroid sits in the Gulf of Mexico, not on land. For labels that must stay inside the shape, you want the pole of inaccessibility, not the centroid; this tool gives you both.

Paste any Polygon, MultiPolygon, Point, or LineString and the tool returns the centroid as a Point feature, plus the pole of inaccessibility (Mapbox's polylabel algorithm) when the input is a polygon. Both points are rendered on the map next to the input geometry so you can see immediately whether the centroid is inside or outside.

Below the calculator: the centre-of-mass formula for polygons, the average-of-vertices shortcut for points, why turf.center() and turf.centroid() give different answers, and the PostGIS equivalents (ST_Centroid, ST_PointOnSurface). Pair this with the bounding box calculator for any geometry summary.

What Is a Centroid?

A centroid is the geometric center of a shape — the point at which the geometry would balance if it were a flat, uniform surface. For a simple rectangle, the centroid is the intersection of the diagonals. For complex polygons, the centroid is calculated as the weighted average of all the vertices, where each triangle formed by consecutive edge segments contributes proportionally to its area.

This tool calculates the centroid of any GeoJSON geometry and returns it as a Point feature. The centroid is displayed on the map alongside the original geometry so you can visually verify its position.

How Centroid Calculation Works

The algorithm computes the centroid across all features in your GeoJSON using the Turf.js centroid function. For FeatureCollections with multiple features, it finds the centroid of the combined geometry. The result is a GeoJSON Point feature with the centroid coordinates.

Note that the centroid of a concave polygon may fall outside the polygon boundary. For example, a crescent-shaped polygon has its centroid in the empty space between the arms. If you need a point guaranteed to be inside the polygon, consider using a "point on surface" algorithm instead, which Turf.js provides as turf.pointOnFeature().

Centroid vs. Center of Mass vs. Point on Surface

These three concepts are related but serve different purposes in geospatial work:

  • Centroid — the arithmetic mean of all coordinates, weighted by area for polygons. Fast to compute but may lie outside concave shapes.
  • Center of mass — identical to the centroid for uniform-density shapes, but can account for weighted features if needed.
  • Point on surface — always guaranteed to be inside or on the boundary of the geometry. Useful for label placement on complex shapes like countries with archipelagos or irregularly shaped districts.

For most web mapping and label placement tasks, the centroid is the right choice. Use point-on-surface only when you need the guarantee that the result lies within the shape.

Common Use Cases

  • Placing labels at the center of polygon features on a map
  • Finding the geographic center of a city, county, or region
  • Creating marker positions from polygon boundary data
  • Calculating distances between the centers of two regions
  • Aggregating point data by computing group centroids
  • Setting the initial map view center from a set of features

Programmatic Equivalent

In JavaScript with Turf.js:

JavaScriptconst centroid = turf.centroid(featureCollection);
console.log(centroid.geometry.coordinates);
// [-73.97, 40.78]

In Python with Shapely:

Pythonfrom shapely.geometry import shape
polygon = shape(geojson_geometry)
print(polygon.centroid.coords[0])

Related tools: area calculator, bounding box calculator, length calculator.