[postgis-users] ST_Force2D on 3D geometries

Regina Obe lr at pcorp.us
Wed Jun 7 01:09:45 PDT 2017


Yes that is expected new behavior.  I think since PostGIS 2.3 when we
changed BOX3D to cast to PolyhedralSurface.

As far as converting a Polyhedralsurface to a Polygon, I'm not sure this is
what you are looking for, but


will return all the patches (faces) of a polyhedralsurface as a set of
polygons. Usually polygon z.

So I'm guessing you are looking for behavior something like this:

SELECT ST_AsText(ST_Union(ST_Force2D(geom)))
FROM ST_Dump('BOX3D(80 -65 -1, 81 -72 5)'::box3d::geometry) AS g(path,geom);

Then again if you only care about the bounding box 2d geometry, you can
always apply to any geometry even polyhedral like so:

SELECT geom::box2d::geometry

Hope that helps,


-----Original Message-----
From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf
Of Hubel, Andreas
Sent: Tuesday, June 06, 2017 5:17 PM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] ST_Force2D on 3D geometries


is the following expected behaviour?

SELECT ST_ASText(ST_Force2D('BOX3D(80 -65 -1, 81 -72 5)'::box3d));

"POLYHEDRALSURFACE(((80 -72,80 -65,81 -65,81 -72,80 -72)),((80 -72,80 -65,81
-65,81 -72,80 -72)),((80 -72,80 -65,80 -65,80 -72,80 -72)),((81 -72,81
-65,81 -65,81 -72,81 -72)),((80 -72,81 -72,81 -72,80 -72,80 -72)),((80
-65,81 -65,81 -65,80 -65,80 -65)))"

To get the result I expected, I had to use following query:

SELECT Box2d(ST_Force2D('BOX3D(80 -65 -1, 81 -72 5)'::box3d));

"BOX(80 -72,81 -65)"

Which only works in this case, as the input is a BOX3D.

Is there a function which converts a POLYHEDRALSURFACE to POLYGON?

Thanks in advance,

More information about the postgis-users mailing list