Geospatial
Area-weighted polygon centroid API
Computes the true area-weighted centroid (center of mass) of a polygon via the shoelace centroid formula with a cosine-latitude correction — not the naive vertex average. Answers 'Where is the geometric center of this polygon?', 'What is the centroid of a geofence for label placement?'.
Price$0.06per request
MethodPOST
Route/v1/geo/polygon-centroid
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
geogispolygoncentroidcenter-of-massshoelacegeofencelabel-pointgeometry
API URL
Integration docshttps://x402.hexl.dev/v1/geo/polygon-centroidExample request
{
"polygon": [
{
"latitude": 0,
"longitude": 0
},
{
"latitude": 0,
"longitude": 4
},
{
"latitude": 3,
"longitude": 4
},
{
"latitude": 3,
"longitude": 0
}
]
}Example response
{
"vertices": 4,
"centroid": {
"latitude": 1.5,
"longitude": 2
},
"method": "area-weighted",
"interpretation": "Area-weighted centroid: 1.5, 2 (the polygon's center of mass, not the vertex average)."
}Input schema
{
"type": "object",
"required": [
"polygon"
],
"properties": {
"polygon": {
"type": "array",
"items": {
"type": "object",
"properties": {
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
}
},
"examples": [
[
{
"latitude": 0,
"longitude": 0
},
{
"latitude": 0,
"longitude": 4
},
{
"latitude": 3,
"longitude": 4
},
{
"latitude": 3,
"longitude": 0
}
]
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}