ST_FlipCoordinates

更新时间:
复制 MD 格式

Returns a version of the input geometry with x and y coordinates swapped. Use this function to fix geometries where coordinates were entered as latitude/longitude (Y, X) instead of longitude/latitude (X, Y).

Syntax

geometry ST_FlipCoordinates(geometry geom);

Parameters

ParameterDescription
geomThe input geometry object.

Supported geometry types

ST_FlipCoordinates supports the following geometry types:

  • Circular strings and curves

  • Polyhedral surfaces

  • Triangles and triangulated irregular network (TIN) surfaces

  • 3D objects

  • M coordinates

Example

SELECT ST_AsText(ST_FlipCoordinates('POINT(0 1)'::geometry));
 st_astext
------------
 POINT(1 0)
(1 row)