Type for geodata

  • GEOMETRY

Description

Type for reading and writing geospatial data, converting between coordinate systems and working with GIS tools.

Examples

Let’s calculate the distance in the plane between two points given in integer coordinates.

SELECT
    ST_Distance('POINT (0 0)'::GEOMETRY, 'POINT (5 12)'::GEOMETRY)
        AS distance;
+----------+
| distance |
+----------+
| 13       |
+----------+

Let’s calculate the distance between the offices of Postgress Pro and Oracle in kilometres.

SELECT
    round(ST_Distance_Sphere('POINT (55.69189394353437, 37.564623398131985)'::GEOMETRY,
                            'POINT (30.243622717202587, -97.72199761339736)'::GEOMETRY
                            )/1000)
    AS "distance between postgress and oracle, km";
+-------------------------------------------+
| distance between postgress and oracle, km |
+-------------------------------------------+
| 9561                                      |
+-------------------------------------------+