ST_Reverse — Devuelve la geometría con el orden de vértice invertido.
geometry ST_Reverse(geometry g1);
Se puede utilizar en cualquier geometría e invierte el orden de los vértices.
Mejorada: 2.4.0 se introdujo el soporte para curvas.
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
WITH data(geom) AS (VALUES (
ST_MakeLine(ST_Point(1, 2), ST_Point(1, 10))
))
SELECT geom AS input_line,
ST_Reverse(geom) AS reversed_line
FROM data;
input_line | reversed_line ----------------------+---------------------- LINESTRING(1 2,1 10) | LINESTRING(1 10,1 2) (1 row)