13

How do I get rid of the Z dimension in PostGIS?

Specifically, I have some MultiPolygonZs that I want to copy into another table as MultiPolygons. I don't care about the Z values - it's okay to just throw them away.

1 Answer 1

19

You should be able to do this with ST_Force2D

This is the example from the manual:

SELECT  ST_AsEWKT(ST_Force2D('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'));

                  st_asewkt
----------------------------------------------
 POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))

It might be possible to use a CAST operator as well (depending on some implicit, not well documented rules), but I'd go with the function on this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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