Fork me on GitHub

ST_Force2D

Signature

GEOMETRY ST_Force2D(GEOMETRY geom);

Description

Converts a 3D Geometry to a 2D Geometry by deleting the z-value of each coordinate if it exists.

Examples

-- No effect on 2D Geometries:
SELECT ST_Force2D('POINT(-10 10)');
-- Answer:         POINT(-10 10)

SELECT ST_Force2D('POINT(-10 10 6)');
-- Answer:         POINT(-10 10)

SELECT ST_Force2D('LINESTRING(-10 10 2, 10 10 3)');
-- Answer:         LINESTRING(-10 10, 10 10)

SELECT ST_Force2D('POLYGON((2 2 2, 10 0 1, 10 5 1, 0 5 2, 2 2 2))');
-- Answer:         POLYGON((2 2, 10 0, 10 5, 0 5, 2 2))

-- Also works on Geometries of mixed dimension:
SELECT ST_Force2D('LINESTRING(-10 10, 10 10 3)');
-- Answer:         LINESTRING(-10 10, 10 10)
See also