ForHosting KIT · Developer Utilities

Convex Hull Perimeter Calculator for Cartesian Points

The convex hull perimeter calculator finds the smallest convex boundary enclosing a set of Cartesian points, then adds the Euclidean length of every boundary edge in order.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It returns both the perimeter and the hull vertices, making the result easy to inspect, plot, or feed into another geometry step. Duplicate points and points inside the boundary do not inflate the answer. The calculation is deterministic, runs without network access, and accepts up to 100,000 input points in a single request.

Provide Cartesian points in a consistent coordinate system

Send the points as records containing finite numeric x and y coordinates. Every point must use the same Cartesian coordinate system and unit. If coordinates are measured in meters, the returned perimeter is in meters; if they are in pixels, the result is in pixels. The calculator does not project latitude and longitude or account for the curvature of Earth, so raw geographic degrees should first be converted to a suitable projected coordinate system when a physical distance is required. Input order is irrelevant because the algorithm sorts the coordinates before constructing the boundary. Repeated coordinates are accepted and removed for geometric purposes, while the response still reports both the original input count and the unique point count. At least one point is required, and the declared limit is 100,000 input records. Keeping coordinates at their original precision avoids unnecessary rounding before distances are evaluated. The returned hull begins at the lexicographically smallest boundary point and proceeds counterclockwise for a stable, reproducible representation.

Understand how the boundary and perimeter are computed

The calculator uses Andrew's monotone-chain method. After sorting and deduplicating the coordinates, it builds a lower chain and an upper chain. A cross-product orientation test removes the middle point whenever three consecutive candidates fail to make a counterclockwise turn. This excludes points strictly inside the hull as well as intermediate points lying on a straight boundary edge, leaving only the extreme endpoints needed to describe that edge. The two chains are joined without repeating their endpoints. The perimeter is then calculated by summing the Euclidean distance from each hull vertex to the next, including the closing edge from the final vertex back to the first. Sorting dominates the running time, giving O(n log n) time complexity, while construction is linear after sorting. For a single unique point, the perimeter is zero. For two unique points, or any entirely collinear set, the hull contains the two extreme endpoints and the closed-boundary convention counts the segment in both directions, producing twice the endpoint distance.

Read the result and use it safely

The perimeter field is the total boundary length in the same unit as the input coordinates. The hull array lists the retained boundary vertices in traversal order without duplicating the first point at the end. The response also includes input_points, unique_points, and hull_points, which help explain why interior, repeated, or collinear points do not appear in the boundary. You can draw the polygon by connecting adjacent returned vertices and explicitly closing the last vertex to the first. Because JavaScript floating-point arithmetic is used, results involving irrational distances may contain the usual small binary floating-point approximation; apply presentation rounding only after receiving the result. This tool is well suited to planar layouts, image coordinates, local engineering grids, and projected mapping data. It does not calculate a spherical or ellipsoidal geodesic perimeter, does not repair coordinate reference mistakes, and does not preserve collinear points merely for display. API requests cost $0.002; the browser execution uses the same pure calculation logic for consistent results across channels.

Measure a site boundary

Find the enclosing perimeter of survey points after they have been converted into a suitable local projected coordinate system.

Estimate a protective enclosure

Calculate the shortest convex fence or wrapping boundary that contains every planar location in a point set.

Summarize a spatial footprint

Return an ordered outline and its length for clusters, detected image features, simulation particles, or CAD coordinates.

What does a request cost?

Each API request costs $0.002. The capability also runs locally in the browser.

Are latitude and longitude supported directly?

They can be supplied as numbers, but the result would be in degrees rather than a reliable physical distance. Project geographic data before calculating a planar perimeter.

What happens to duplicate and interior points?

Duplicates are removed, and interior points are excluded from the hull. The response counts original, unique, and hull points separately.

How are collinear points handled?

Only the two extreme endpoints remain. Their segment is counted twice because the degenerate hull boundary travels out and back.

Is the first hull point repeated at the end?

No. The hull array contains each retained vertex once; the closing edge back to the first vertex is implicit and included in the perimeter.

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/geo/convex-hull-perimeter

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/geo/convex-hull-perimeter \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"points":[{"x":0,"y":0},{"x":4,"y":0},{"x":4,"y":3},{"x":0,"y":3},{"x":2,"y":1}]}'
{
  "points": [
    {
      "x": 0,
      "y": 0
    },
    {
      "x": 4,
      "y": 0
    },
    {
      "x": 4,
      "y": 3
    },
    {
      "x": 0,
      "y": 3
    },
    {
      "x": 2,
      "y": 1
    }
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geo.convex_hull_perimeter",
  "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_items100000
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.

Read the full KIT documentation →