ForHosting KIT · Math

Centroid calculator

Find the middle of a set of points by averaging their coordinates: (0, 0), (4, 0) and (0, 3) have their centroid at (1.3333333333, 1). Use it for delivery stops, sensor positions or the corners of a plot. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

The centroid calculator finds the geometric center of a set of points — the balance point you get by averaging every x coordinate and every y coordinate. Send a list of points and receive the centroid coordinates back, together with the number of points that were averaged.

What a centroid actually is

Take a handful of points on a plane — delivery stops, sensor positions, corners of a plot of land — and ask where their middle is. The centroid is the honest answer: you add up all the x coordinates and divide by the number of points, then do the same for the y coordinates. The result is the single location that balances the whole set.

If the points were equal weights glued to a weightless sheet, the sheet would rest level on a pin placed exactly at the centroid. That intuition matters because it tells you what the number is good for: it represents the set as a whole, not any individual member. Move one point and the centroid moves with it, by exactly one Nth of that movement.

Add a duplicate of an existing point and the centroid is pulled toward it. The centroid calculator applies this arithmetic mean formula directly, with no weighting, no area correction and no assumptions about order — every point counts once and counts equally.

How the computation works

Numeric strings are accepted and converted, which makes life easier when the data comes straight from a form or a CSV column. Every coordinate must be a finite number within a generous absolute bound; a missing field, a non-numeric value or an out-of-range magnitude fails fast with a clear error that names the offending point, rather than silently corrupting the average.

An empty list is rejected outright, because a centroid over zero points is undefined — division by zero would produce NaN, and shipping NaN back to a caller is how bugs travel downstream undetected. Results are rounded to ten decimal places so that the same input produces byte-identical output on any machine, which keeps automated tests and audit trails stable across platforms and over time.

Centroid versus other notions of center

The word center hides several different ideas, and picking the wrong one gives a misleading answer. The arithmetic-mean centroid computed here treats each point as an equal vote, which is right when points are observations: customer locations, sample sites, click positions. It is not the area-weighted centroid of a polygon, which answers where a shape's mass lies and depends on the region enclosed, not on how many vertices happen to describe it — for that, a polygon centroid capability exists separately.

It is also not a median center, which resists outliers, nor a weighted center of mass, where some points matter more than others. If one far-away point dominates your mean, the honest conclusion is that the mean reflects it; decide first whether that point belongs in the set at all. For equal-importance 2D point sets, the arithmetic centroid remains the standard, cheapest and most interpretable summary, and it is exactly what this capability returns in a single deterministic call.

Find the center of customer locations

Average the coordinates of your delivery stops or store visitors to place a warehouse or meeting point at the balance of the set.

Summarize sensor or sample positions

Reduce a batch of GPS samples or measurement sites to one representative coordinate for dashboards and reports.

Center a canvas or annotation

Compute the mean of selected points in a graphics or mapping tool to position labels, markers or camera focus.

What happens with an empty point list?

A centroid over zero points is undefined, so it is rejected instead of returning a meaningless value.

Is there a limit on the number of points?

Larger sets should be averaged in batches and combined as a weighted mean of partial sums.

Are the points weighted?

No. Every point counts once and equally; this is the plain arithmetic mean of the coordinates, not an area- or mass-weighted centroid.

Is my data stored?

No. The coordinates are processed in memory and discarded; only the centroid is returned.

Is this the same as the centroid of a polygon?

No. The centroid of a polygon's area depends on the region it encloses, not on how many corners describe it. This tool averages the points themselves, which is right when they are observations such as customer locations, sample sites or clicks.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/centroid

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/centroid \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"points":[{"x":0,"y":0},{"x":4,"y":0},{"x":0,"y":3}]}'
{
  "points": [
    {
      "x": 0,
      "y": 0
    },
    {
      "x": 4,
      "y": 0
    },
    {
      "x": 0,
      "y": 3
    }
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.centroid",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_points100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

It works for one point or one hundred thousand, it never touches a server-side file, and the exact same code that answers the paid API runs free on this page, so what you try here is what you automate later.

How the computation works

The endpoint accepts a JSON array of points, each one an object with an x and a y coordinate, and returns the count of points, the averaged coordinates and the method used.

What does it cost?

$0.002 per request. It is also free to run in your browser on this page.

What input does it expect?

A JSON array named points, where each element is an object with numeric x and y coordinates. Numeric strings are converted automatically.

Read the full KIT documentation →