ForHosting KIT · Developer Utilities

Densify a geodesic line with evenly spaced latitude/longitude vertices

Densify a geographic line by inserting intermediate latitude and longitude vertices along every segment.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Supply an ordered line and a maximum spacing in meters; the result follows the shorter great-circle arc and guarantees that each generated gap is no longer than that spacing. Original vertices remain in order, while useful counts and distance summaries make the output easy to inspect, map, or pass into another spatial workflow without relying on a GIS desktop application.

Choose a spacing that matches the downstream job

Line densification is useful when an operation needs samples more frequently than the source geometry provides. Start with an ordered array of records containing lat and lon, then set spacing_m to the largest acceptable gap in meters. The calculator evaluates every original segment independently. If a segment is already shorter than the requested spacing, it is kept as one gap and no unnecessary point is inserted. If it is longer, the segment is divided into the smallest whole number of equal-length geodesic gaps that satisfy the maximum. This distinction matters: the spacing is a ceiling, not a demand that every gap equal the supplied value exactly. Because each original segment is divided separately, its endpoint is preserved and the next segment begins from precisely the original vertex. Use a coarse spacing for overview maps or lightweight previews, and a finer spacing when samples feed terrain lookup, coverage checks, animation, or calculations that assume short edges. Very small spacing can create a large result, so the capability rejects requests that would exceed its documented output limit instead of silently truncating the line.

Understand the spherical geodesic calculation

Each pair of consecutive coordinates defines a segment on a sphere. The algorithm converts both endpoints to three-dimensional unit vectors, measures their central angle, and interpolates along the shorter great-circle arc. Distance is that angle multiplied by earth_radius_m, whose default is the conventional mean Earth radius. This method behaves correctly across the antimeridian: a line from 179 degrees east to 179 degrees west follows the short route across the date line rather than traveling around most of the globe. It also avoids treating latitude and longitude as flat Cartesian coordinates, an approximation that becomes visibly misleading over long distances or near the poles. The returned original and inserted coordinates are deterministic and rounded to stable precision for dependable JSON comparisons. Coincident consecutive points are retained because they may carry structural meaning in the source line, although their gap has zero length. Exactly antipodal endpoints are rejected because infinitely many great-circle arcs connect opposite points, so there is no unique shorter path to densify. For ellipsoidal survey-grade work, remember that this capability uses a configurable sphere rather than a full WGS-84 ellipsoid.

Read and validate the result

The primary result is vertices, an ordered array ready to serialize as coordinates or transform into the geometry format used by your application. The first and last coordinates are the source endpoints, and every original interior vertex appears at its segment boundary. The response also reports input_vertices, output_vertices, and inserted_vertices, which make expansion explicit and help enforce storage or rendering budgets. total_distance_m is the sum of the original geodesic segment lengths. max_segment_distance_m is the largest actual output gap after subdivision, so it should be less than or equal to the requested spacing apart from harmless floating-point rounding. Validate that field when densification protects a downstream sampling requirement. Preserve the coordinate order when converting the result to GeoJSON, where coordinate pairs normally use longitude before latitude even though this API uses named lat and lon properties. The calculation is pure, performs no network requests, and does not retain the submitted line. Browser execution can handle interactive checks, while automated API use costs $0.002 per request and returns the same deterministic structure.

Prepare a route for regular sampling

Add enough vertices before querying elevation, weather, signal coverage, or another value that changes along a route.

Improve long-edge map rendering

Represent long geographic edges with intermediate great-circle points so projected or animated paths follow the intended route.

Normalize mixed-resolution line data

Apply one maximum-gap rule to lines whose source vertices were captured at inconsistent intervals.

Does spacing_m set an exact distance between every point?

No. It sets the maximum allowed gap. Each original segment is divided into equal geodesic pieces, all no longer than that value.

Are the original vertices preserved?

Yes. Every original vertex remains in order, and new vertices are inserted between consecutive originals.

Does it work across the antimeridian?

Yes. Interpolation follows the shorter great-circle arc, including the short crossing between positive and negative longitudes near 180 degrees.

Why are antipodal endpoints rejected?

Opposite points have no unique great-circle path. Rejecting that ambiguous segment avoids choosing an arbitrary route.

Is this based on the WGS-84 ellipsoid?

No. It uses spherical great-circle geometry with a configurable radius, defaulting to the mean Earth radius.

What does an API request cost?

Each request costs $0.002. The deterministic calculation performs no third-party network calls.

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/densify-line

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/densify-line \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"line":[{"lat":37.7749,"lon":-122.4194},{"lat":37.8044,"lon":-122.2711},{"lat":37.6879,"lon":-122.4702}],"spacing_m":5000}'
{
  "line": [
    {
      "lat": 37.7749,
      "lon": -122.4194
    },
    {
      "lat": 37.8044,
      "lon": -122.2711
    },
    {
      "lat": 37.6879,
      "lon": -122.4702
    }
  ],
  "spacing_m": 5000
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geo.densify_line",
  "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_points10000
max_output_vertices100000
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 →