# 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](https://en.wikipedia.org/wiki/Great-circle_distance).

![](https://images.contentstack.io/v3/assets/bltac01ee6daa3a1e14/bltd02f4f6a8ed4316d/6a2c42fb970cc7839b446f5f/distance-u4NVXL.png)

## 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

```sql
CREATE ROWSTORE TABLE neighborhoods (
  id INT UNSIGNED NOT NULL PRIMARY KEY,
  name VARCHAR(64) NOT NULL,
  population INT UNSIGNED NOT NULL,
  shape GEOGRAPHY NOT NULL,
  centroid GEOGRAPHYPOINT NOT NULL,
  index (shape) WITH (resolution = 8),
  index (centroid)
  );

  INSERT INTO neighborhoods VALUES
  (1, "Hamilton", 12346, "POLYGON((1 1,2 1,2 2, 1 2, 1 1))","POINT(1.5 1.5)"),
  (2, "Probability Bay", 263951, "POLYGON((5 1,6 1,6 2,5 2,5 1))", "POINT(5.5 1.5)"),
  (3, "Decentralized Park", 29265, "POLYGON((5 5,6 5,6 6,5 6,5 5))", "POINT(5.5 5.5)"),
  (4, "Axiom Township", 845696, "POLYGON((1 5,2 5,2 6,1 6,1 5))", "POINT(1.5 5.5)"),
  (5, "Elegant Island ", 987654, "POLYGON((3 3,4 3,4 4,3 4,3 3))", "POINT(3.5 3.5)");
```

```sql
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;

```

```output

+---------------------+----------------------+
| neighbor            | distance_from_border |
+---------------------+----------------------+
| Axiom Township      | 471030.0             |
| Decentralized Park  | 333399.0             |
| Elegant Island      | 157090.0             |
| Hamilton            | 333195.0             |
| Probability Bay     | 0.0                  |
+---------------------+----------------------+

```

## Related Topics

For more information about working with geospatial data, see [Working with Geospatial Features](https://docs.singlestore.com/db/v9.1/developer-resources/functional-extensions/working-with-geospatial-features.md).

***

Modified at: February 23, 2023

Source: [/db/v9.1/reference/sql-reference/geospatial-functions/geography-distance/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/geospatial-functions/geography-distance/)

(An index of the documentation is available at /llms.txt)
