[GIS] postgis error: when adding features geometry has z dimension but column does not

dxfgeometrypostgisqgis

I have to define a geometry column in PostGIS for 2D points, but when I try to import points from DXF to postgres I get the following message:

"postgis error: when adding features geometry has z dimension but
column does not"

Is there any way to change DXF files to be 2D geometry? I have tried this with the comand Flatten in autocad but the same error appears.

Best Answer

There may be a more elegant solution, but can you import the points as 3-D points, and then create a 2-D point in Postgres? For example ST_X( 3dpoint ) and ST_Y( 3dpoint ) would give you the x and y coordinates so you could then create a point using:

ST_SetSRID(
    ST_MakePoint(
        ST_X( 3dpoint ), ST_Y( 3dpoint )
                 ), 900913) 

I don't know what form your initial data is in, so perhaps you can just use the x and y values by themselves.

Related Question