Geolocation Utilities

Polygon Centroid

Calculate the geometric center point of any polygon using coordinate arrays. Access via MCP in Cursor or Windsurf, or hit GET /v1/geo/centroid directly. Pass polygon vertices as lat/lng pairs, get back precise centroid coordinates. Uses standard centroid algorithm for irregular polygons — essential for mapping applications and spatial analysis.

API Endpoint

GET /v1/geo/centroid

Code Examples

curl "https://tinyfn.io/v1/geo/centroid" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/geo/centroid', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/geo/centroid',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's geolocation tools:

{
  "mcpServers": {
    "tinyfn-geo": {
      "url": "https://tinyfn.io/mcp/geo",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate polygon centroid with coordinate arrays?

Send polygon vertices as an array of [lat, lng] coordinate pairs to the centroid endpoint. The tool returns the geometric center point using the standard polygon centroid formula.

What coordinate format does the polygon centroid tool accept?

Accepts arrays of latitude/longitude pairs in decimal degrees format. Vertices should be ordered (clockwise or counterclockwise) to define the polygon boundary properly.

Can MCP tools like Cursor calculate centroids for irregular polygons?

Yes, the centroid tool handles any polygon shape through MCP integration. Works with irregular polygons, complex boundaries, and multi-sided shapes using geometric centroid calculation.

Does polygon centroid calculation work for self-intersecting polygons?

The tool calculates geometric centroids for simple polygons. Self-intersecting or overlapping polygons may produce unexpected results since the standard algorithm assumes non-intersecting boundaries.

What's the difference between centroid and geographic center of a polygon?

Centroid is the geometric center based on polygon shape, while geographic center considers Earth's curvature. This tool provides geometric centroid using Cartesian coordinates.

Try Polygon Centroid Now

Get your free API key and start using Polygon Centroid in seconds.

Get Free API Key