13

I have a Point table in which the geometry column contains both 3 dimension and 2 dimension values. I want to convert this 3 dimensional geometry to 2 dimension.

Is there any function in PostGIS?

0

2 Answers 2

18

http://postgis.net/docs/manual-2.0/ST_Force_2D.html

SELECT ST_Force_2D(the_geom) FROM...

Update your existing table

 
ALTER TABLE your_geo_table ADD geom2d geometry;
UPDATE your_geo_table SET geom2d = ST_Force_2D(the_geom);

See also http://postgis.net/docs/

1
  • 2
    Use ST_Force2D instead of ST_Force_2d. ST_Force_2d signature was deprecated in 2.1.0.
    – jgrocha
    Jan 19, 2017 at 16:05
13

If you don't want to add a new column you can also do the following:

ALTER TABLE your_geo_table  
  ALTER COLUMN geom TYPE geometry(YOUR_GEOM_TYPE, YOUR_EPSG) 
    USING ST_Force_2D(geom);

For example:

ALTER TABLE your_geo_table  
  ALTER COLUMN geom TYPE geometry(MULTILINESTRING, 4326) 
    USING ST_Force_2D(geom);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.