Model / geo · All operations
Measure distance between places
A variant of Work with geography
Compute the distance between two points or geometries, planar, great-circle or by road.
Status
- In arcform
Not built yet
arcform does not do this yet. Its place on the roadmap
What other tools call it
Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).
Alteryx Designer (1)
Distanceread 2026-09-27Compute point-to-point, point-to-edge or drive distance between two spatial objects
Bruin (1)
bruin.haversine_distance(lat1, lon1, lat2, lon2, unit='mi')read 2026-09-27Emit a haversine distance expression in miles or kilometres
dbt-utils (1)
haversine_distanceread 2026-09-27Compute great-circle distance between two lat/lon points in miles or kilometres
Duckle (1)
Spatial Distanceread 2026-09-25distance from each row to a target geometry, planar or spheroid by CRS
Ibis (2)
GeoDistanceread 2026-09-27Minimum distance between two geometries
GeoMaxDistanceread 2026-09-27Largest 2D distance between two geometries
SQLMesh (1)
@HAVERSINE_DISTANCEread 2026-09-27Compute haversine distance between two lat/lon points in miles or kilometres
Background
Geographical distance, or geodetic distance, is the distance measured along the surface of the Earth, or the shortest arc length.[1] The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes.[2] Vincenty's formulae calculate the distance between two points on a spheroid, and are more accurate than methods that assume a spherical Earth.[3]
When to use it
Because the Earth is nearly spherical, great-circle distance formulas applied to longitude and geodetic latitude are accurate to within about 0.5%.[4] In DuckDB's spatial extension, ST_Distance returns the planar distance between two geometries, while ST_Distance_Sphere returns the haversine distance in metres and supports only points.[5] In PostGIS, a geometry-type distance between longitude and latitude coordinates comes out in nominal degrees that do not correspond to any true angular difference between the points.[6] Never take a planar distance over raw longitude and latitude: use a sphere or ellipsoid function, or project the points into metres first. (Meridian's view)
The method
The haversine formula is a special case of the law of haversines, a formula in spherical trigonometry that relates the sides and angles of spherical triangles.[2] The first table of haversines in English was published by James Andrew in 1805, and the term haversine, a contraction of half-versed sine, was coined in 1835 by James Inman.[2]
Vincenty's formulae, developed by Thaddeus Vincenty in 1975, have been widely used in geodesy because they are accurate to within 0.5 mm on the Earth ellipsoid.[3] In DuckDB's spatial extension, ST_Distance_Spheroid uses the GeographicLib library to solve the inverse geodesic problem on an ellipsoidal model of the earth.[5]
Dijkstra's algorithm finds the shortest paths between nodes in a weighted graph, which may represent a road network, and was conceived by Edsger W. Dijkstra in 1956.[7]
Sources
- [1]Geographical distance - Wikipediasecondary source
- [2]Haversine formula - Wikipediasecondary source
- [3]Vincenty's formulae - Wikipediasecondary source
- [4]Great-circle distance - Wikipediasecondary source
- [5]Spatial Functions – DuckDBdocumentation
- [6]Chapter 4. Data Managementdocumentation
- [7]Dijkstra's algorithm - Wikipediasecondary source