SingleStore Managed Service

GEOGRAPHY_DISTANCE

This function takes in two geospatial objects and measures the shortest distance between them, in meters, using the standard metric for distance on a sphere.

image
Syntax
GEOGRAPHY_DISTANCE ( geo1, geo2 )
Arguments
  • geo1, geo2: any valid geospatial object or WKT string: path, point or polygon.

Return Type

A double. The measured distance, in meters.

Examples
SELECT b.name AS neighbor,
    -> ROUND(GEOGRAPHY_DISTANCE(a.shape, b.shape), 0) AS distance_from_border
    -> FROM neighborhoods a, neighborhoods b
    -> WHERE a.id = 2
    -> ORDER BY 1;
+---------------------+----------------------+
| neighbor            | distance_from_border |
+---------------------+----------------------+
| Probability Bay     |                    0 |
| Lower Bound Valley  |                    0 |
| Axiom Township      |                    0 |
| Elegant Island      |                 1935 |
| Upper Bound Hill    |                 5632 |
| Big Endian          |                 9016 |
| Little Endian       |                17290 |
| Isle Zero           |                17163 |
...