Fork me on GitHub

ST_RemoveRepeatedPoints

Signature

GEOMETRY ST_RemoveRepeatedPoints(GEOMETRY geom);

Description

Removes repeated points from geom.

Examples

SELECT ST_RemoveRepeatedPoints(
            'LINESTRING(1 1, 2 2, 2 2, 1 3, 1 3,
                        3 3, 3 3, 5 2, 5 2, 5 1)');
-- Answer:   LINESTRING(1 1, 2 2,      1 3,
--                      3 3,      5 2,      5 1)

SELECT ST_RemoveRepeatedPoints(
            'POLYGON((2 4, 1 3, 2 1, 2 1, 6 1,
                      6 3, 4 4, 4 4, 2 4))');
-- Answer:   POLYGON((2 4, 1 3, 2 1,      6 1,
--                    6 3, 4 4,      2 4))

SELECT ST_RemoveRepeatedPoints(
        'GEOMETRYCOLLECTION(
             POLYGON((1 2, 4 2, 4 6, 1 6, 1 6, 1 2)),
             MULTIPOINT((4 4), (1 1), (1 0), (0 3)))');
-- Answer: GEOMETRYCOLLECTION(
--           POLYGON((1 2, 4 2, 4 6, 1 6,      1 2)),
--           MULTIPOINT((4 4), (1 1), (1 0), (0 3)))

-- Here POINT(4 4) is not removed since it is an independant
-- geometry:
SELECT ST_RemoveRepeatedPoints(
            'MULTIPOINT((4 4), (1 1), (1 0), (0 3), (4 4))');
-- Answer:   MULTIPOINT((4 4), (1 1), (1 0), (0 3), (4 4))
See also