Returns the smallest distance between the geometry-expression and the specified geometry value.
SELECT ShapeID, ROUND( Shape.ST_Distance( NEW ST_Point( 2, 3 ) ), 2 ) AS dist FROM SpatialShapes WHERE ShapeID < 17 ORDER BY dist
ShapeID | dist |
---|---|
2 | 0.0 |
3 | 0.0 |
5 | 1.0 |
6 | 1.21 |
16 | 1.41 |
1 | 5.1 |
The following example creates points representing Halifax, NS and Waterloo, ON, Canada and uses ST_Distance to find the distance between the two points in miles, returning the result 846. This example assumes that the 'st_geometry_predefined_uom' feature has been installed by the sa_install_feature system procedure. Seesa_install_feature system procedure.
SELECT ROUND( NEW ST_Point( -63.573566, 44.646244, 4326 ) .ST_Distance( NEW ST_Point( -80.522372, 43.465187, 4326 ) , 'Statute mile' ), 0 )
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.23