I am trying to make a web application that renders 3D buildings (LoD1). I have a PostGIS (2.2.1dev) database which contains the 2D geometry of the buildings and the height. I used st_extrude to make a 3D geometry out of it.

The problem is that I end up with a PolyhedralSurface, while I need a MultiPolygon. I used st_dump to split up my polyhedralSurface into its faces (floor, roof, walls). I end up with a table that has an id-column and a geometry-column.

For each building, I now have multiple rows in the table. The geometry column is of the form:

({1}, 01030000A8...).

The {i} part is the identifier for which face of my building it is, the second part is the actual geometry of this face.

How can I join the multiple rows for one building together and end up with a MultiPolygon?

1 Answer 1


I think I figured it out myself...

CREATE TABLE buildings_extrude AS
SELECT id, st_extrude(geom, 0, 0, height) as the_geom
FROM buildings;

CREATE TABLE buildings_dump AS
SELECT id, st_dump(the_geom) as the_geom
FROM buildings_extrude;

CREATE TABLE buildings_collect AS
SELECT id, st_collect((the_geom).geom) as the_geom
FROM buildings_dump

Your Answer

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

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