3

I am unable to store a polyhedralsurface object in my POSTGIS database.

My table has two columns:

name character varying,
geom geometry(POLYHEDRALSURFACE)

I am trying to insert the following geometry:

INSERT INTO public.geometries(
        name, geom)
VALUES ('Cube', ST_GeomFromEWKT('SRID=4326;POLYHEDRALSURFACE( 
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),  
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), 
((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), 
((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),  
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),  
((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) 
)'));

but POSTGIS throws an error:

Geometry has Z dimension but column does not
4

Found solution :D

You can either set your geometry as GeometryZ at time of creation like this

geom geometry(GeometryZ,4326)

Or use AddGeometryColumn function

SELECT AddGeometryColumn( 'geometries', 'geom', 4326, 'GEOMETRY', 3 );

If anyone has a better solution, please comment. Thanks!

2

Change your geometrytype to POLYHEDRALSURFACEZ, that should do the trick. This is not well documented in the postgis documentation I think.

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.