How to Find the Center of a Polygon

API or service
Geometry Operations API
Task
Polygon + center definition → representative point
Examples
URL
Difficulty
Intermediate
Time
10 min

Find the center of a polygon

You have a Polygon or other GeoJSON geometry and need one representative point for a label, marker, comparison, or summary. “Center” can mean several different things, so choose the definition that matches the task before calculating it.

Task flow: geometry + center definition → representative GeoJSON Point.

This guide compares center, centerMean, centerMedian, and centerOfMass using the same concave polygon. Different vertex placement and geometry shape produce different answers.

Choose a center method

Requirement Operation What it represents
Center a map on the geometry's extent center Midpoint of the bounding box.
Average the submitted positions centerMean Mean of the geometry vertices; sensitive to where vertices are concentrated.
Reduce the influence of distant vertices centerMedian An iteratively calculated median center of the vertices.
Find the geometric balance point of a polygon centerOfMass Area-weighted center of mass. Usually the best starting point for polygon analysis.

For a regular rectangle, these results may be identical or nearly identical. Concave, multipart, or unevenly digitized geometry makes their differences visible.

None of these methods guarantees that its point lies inside a concave Polygon or one particular part of a MultiPolygon. If an inside point is required for a label or interaction, check the returned point against the polygon and apply a dedicated inside-point strategy when necessary.

Calculate four center points

Send one operation per request to the same endpoint:

POST https://api.geoapify.com/v1/geometry/operation?apiKey=YOUR_API_KEY
Content-Type: application/json

For example, calculate the center of mass of this L-shaped polygon:

{
  "operation": "centerOfMass",
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [13.38, 52.50], [13.46, 52.50],
      [13.46, 52.52], [13.40, 52.52],
      [13.40, 52.58], [13.38, 52.58],
      [13.38, 52.50]
    ]]
  }
}

Repeat the request with only the operation value changed. Validated responses for this exact geometry are:

Operation Returned [longitude, latitude]
center [13.420000, 52.540000]
centerMean [13.408571, 52.528571]
centerMedian [13.413333, 52.533333]
centerOfMass [13.407143, 52.527143]

Each response wraps the Point in a GeoJSON Feature:

{
  "type": "geojson",
  "data": {
    "type": "Feature",
    "properties": {},
    "geometry": {
      "type": "Point",
      "coordinates": [13.40714285714286, 52.527142857142856]
    }
  }
}

Use the full-precision coordinates for subsequent calculations and round only for display.