ST_FlipCoordinates

更新时间:
复制 MD 格式

Returns a version of the input geometry with its X and Y axes swapped. Useful for correcting geometries where the X and Y coordinates are entered in reverse order.

Syntax

geometry ST_FlipCoordinates(geometry geom);

Parameters

ParameterDescription
geomThe geometry object whose X and Y coordinates are swapped.

Usage notes

  • Supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.

  • Supports M coordinates.

Examples

Swap the X and Y coordinates of a point:

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

Result:

 st_astext
------------
 POINT(1 0)
(1 row)