Skip to content

ST_MaxDistance

Returns the maximum distance between any pair of points in two geometries or geographies.

Usage

double ST_MaxDistance(geogA: geography, geogB: geography)

Arguments

  • geogA (geography): Input geography
  • geogB (geography): Input geography

Description

For geography, returns the maximum distance in meters calculated using a spherical approximation.

Examples

SELECT ST_MaxDistance(
    ST_GeogFromText('POLYGON ((0 0, 1 0, 0 1, 0 0))'),
    ST_GeogFromText('POLYGON ((10 10, 11 10, 10 11, 10 10))')
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_maxdistance(st_geogfromtext(Utf8("POLYGON ((0 0, 1 0, 0 1, 0 0))")),st_ge │
│         ogfromtext(Utf8("POLYGON ((10 10, 11 10, 10 11, 10 10))")))…         │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                           1648412.0099053395 │
└──────────────────────────────────────────────────────────────────────────────┘