Pythagorean equirectangular distance
Get a quick ground distance between two nearby points by treating the map as a flat local plane: two Manhattan coordinates come out just over 5 km apart. You also see the north-south and east-west legs in metres. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Lat1
- 40.7128
- Lon1
- -74.006
- Lat2
- 40.758
- Lon2
- -73.9855
- Distance m
- 5,314.523521
- Distance km
- 5.314523521
- Delta lat m
- 5,026.010684
- Delta lon m
- 1,727.245453
This capability estimates how far two points on Earth are from each other by treating the map as a local flat plane. It converts the difference in latitude and longitude into metres using a mean-latitude cosine scale, then applies the Pythagorean theorem to those east-west and north-south offsets. The result is an approximate ground distance in metres and kilometres, plus the projected deltas so you can audit the intermediate steps. The algorithm is fully deterministic: no network calls, no random sampling and no clock. Use it when you need a quick, cheap distance for nearby points, batch ranking, or teaching the equirectangular projection without the cost of a full great-circle formula.
How the Pythagorean equirectangular formula works
On a sphere, true shortest paths are great circles, but for many product and analysis tasks a flat local approximation is enough. This tool uses the classic equirectangular projection: convert both latitudes and longitudes to radians, take the difference in latitude as the north-south arc on a sphere of fixed mean radius, and scale the longitude difference by the cosine of the average latitude so that east-west metres shrink near the poles. Those two metre offsets become the legs of a right triangle.
The hypotenuse is the reported ground distance. We use a mean Earth radius of six million three hundred seventy-one thousand metres, the same constant many educational and GIS primers use for this method.
Valid coordinates and when a value is refused
Send decimal degrees on the WGS84 globe. Latitude fields lat1 and lat2 must sit between minus ninety and ninety inclusive. Longitude fields lon1 and lon2 must sit between minus one hundred eighty and one hundred eighty inclusive.
Out-of-range latitudes or longitudes fail the same way with a message that names the offending field. Prefer stable decimal numbers rather than degree-minute-second text or grid references; convert those formats before you call. The params example uses a short Manhattan pair so the probe and documentation stay realistic.
For identical points the distance is zero. Crossing the antimeridian with raw longitude differences can inflate the result; for paths that wrap the date line, normalise longitudes first or use a great-circle method instead.
When to use this approximation versus a spherical formula
Choose the Pythagorean equirectangular distance when points are relatively close, when you need maximum speed over maximum accuracy, or when you are teaching or debugging map projections and want intermediate metre deltas. Delivery radius checks inside a city, clustering of nearby sensors, rough travel-time heuristics and UI tooltips all fit well. For intercontinental routes, polar paths, or navigation where a few percent error matters, prefer a haversine or Vincenty-style great-circle distance instead: those methods account for Earth curvature more carefully.
Error grows with separation and with latitude extremes because the flat projection ignores meridional convergence beyond the mean-latitude scale factor. Always document the method when you store results so later audits know you used an approximation. Invalid inputs never consume balance, so you can validate coordinates aggressively before batch jobs.
What you can do with it
City-scale proximity ranking
Sort stores, sensors or pick-up points by approximate ground metres from a user without loading a heavy geospatial library.
Teaching map projections
Show students how lat/lon deltas become east-west and north-south metres, then a Pythagorean hypotenuse, with live numbers.
FAQ
How accurate is the Pythagorean equirectangular method?
It is a local flat approximation. Accuracy is good for short and medium distances and degrades as separation grows or near the poles. For long great-circle routes use a spherical formula instead.
What does it cost?
The page tool is free in your browser. Invalid inputs are not charged.
How do I get the distance between two nearby coordinates?
Enter the latitude and longitude of both points in decimal degrees. You get the distance in metres and kilometres, plus the north-south and east-west offsets that form the two legs of the right triangle.
Why do east-west metres shrink near the poles?
Because meridians converge as you move away from the equator. The longitude difference is multiplied by the cosine of the average latitude, so the same gap in degrees covers fewer metres at high latitudes.
What if my two points lie on either side of the 180° meridian?
The raw longitude difference then spans almost the whole globe and the distance comes out far too large. Normalise the longitudes first, or use a great-circle method for paths that cross the date line.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geo/pythagorean-geo-distance \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"lat1":40.7128,"lon1":-74.006,"lat2":40.758,"lon2":-73.9855}'const res = await fetch("https://api.kit.forhosting.com/geo/pythagorean-geo-distance", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"lat1": 40.7128,
"lon1": -74.006,
"lat2": 40.758,
"lon2": -73.9855
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geo/pythagorean-geo-distance",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"lat1": 40.7128,
"lon1": -74.006,
"lat2": 40.758,
"lon2": -73.9855
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geo/pythagorean-geo-distance", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"lat1":40.7128,"lon1":-74.006,"lat2":40.758,"lon2":-73.9855}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"lat1":40.7128,"lon1":-74.006,"lat2":40.758,"lon2":-73.9855}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geo/pythagorean-geo-distance", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"lat1": 40.7128,
"lon1": -74.006,
"lat2": 40.758,
"lon2": -73.9855
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geo.pythagorean_geo_distance",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How the Pythagorean equirectangular formula works
The response echoes the four coordinates you sent, the distance in metres and kilometres, the signed delta_lat_m and delta_lon_m components, the method name, and the radius constant so downstream code can log provenance without reverse-engineering the formula.
Input ranges, aliases and when the call fails
Common aliases are accepted: latitude1, from_lat, longitude1, from_lon, from_lng, latitude2, to_lat, longitude2, to_lon and to_lng map to the same four required numbers. Values may arrive as JSON numbers or numeric strings; non-finite values, empty strings and missing required fields fail with invalid_input and are not billed.
When to use this approximation versus a spherical formula
Run the free browser tool to inspect a single pair, or call the API when automation needs the same deterministic result at $0.002 per successful request.
Integration use cases
Batch pipeline distance features
Add a cheap, deterministic distance_m column to CSV or event streams for analytics and ML features on short ranges.
Technical questions
What does this calculator return?
It returns the two points, distance in metres and kilometres, the projected latitude and longitude deltas in metres, the method label pythagorean_equirectangular, and the Earth radius constant used.
When does the call fail?
It fails with invalid_input when a required coordinate is missing or not finite, or when latitude is outside −90…90 or longitude is outside −180…180.
Is the browser result the same as the API?
Yes. Both run the same pure solve() in lib.js, so identical inputs produce identical distances and deltas.