Returns the farthest distance between two geometry objects, measured in the units of their spatial reference system (SRS).
Syntax
float ST_MaxDistance(geometry g1, geometry g2)Parameters
| Parameter | Description |
|---|---|
g1 | The first geometry object. |
g2 | The second geometry object. |
Usage notes
If g1 and g2 are the same object, the function returns the distance between the two farthest vertices of that object.
Examples
Calculate the farthest distance between two line strings:
SELECT ST_MaxDistance('LINESTRING (0 0,-1 1)'::geometry, 'LINESTRING (0 0,1 1)'::geometry);
st_maxdistance
----------------
2
(1 row)