Skip to content

ST_Distance

Returns the distance between two geometries or geographies.

Usage

double ST_Distance(geomA: geometry, geomB: geometry)
double ST_Distance(geogA: geography, geogB: geography)

Arguments

  • geogA (geography): Input geography
  • geogB (geography): Input geography
  • geomA (geometry): Input geometry
  • geomB (geometry): Input geometry

Description

For geometry, returns the 2D Cartesian (planar) distance between two geometries, in the units of the coordinate reference system. For geography, returns the spherical approximation of the geodesic distance between two geographies in meters.

Examples

SELECT ST_Distance(ST_Point(0, 0), ST_Point(1, 1));
┌──────────────────────────────────────────────────────────────────────┐
│ st_distance(st_point(Int64(0),Int64(0)),st_point(Int64(1),Int64(1))) │
│                                float64                               │
╞══════════════════════════════════════════════════════════════════════╡
│                                                   1.4142135623730951 │
└──────────────────────────────────────────────────────────────────────┘
SELECT ST_Distance(ST_GeogPoint(0, 0), ST_GeogPoint(1, 1));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_distance(st_geogpoint(Int64(0),Int64(0)),st_geogpoint(Int64(1),Int64(1))) │
│                                    float64                                   │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                            157249.6280925079 │
└──────────────────────────────────────────────────────────────────────────────┘