0

I'm trying to make a postgis table ready for pgrouting. When I run :

SELECT pgr_createTopology('network.VEJM_BR_SL', 0.001, 'geom', 'id');

I get an error:

"Geometry has Z dimension but column does not"

It seems related to the "geom" column being the type "LinestringZ". I believe it means that it is with Z values. I've tried to use ST_Force2D like this:

SELECT pgr_createTopology('network.VEJM_BR_SL', 0.001, ST_Force2D('geom'), 'id'); 

but it does not work. Any suggestions?

1

Unfortunately that parameter needs to be a column name, so you can't apply a function to it since it builds an sql internally. If you don't need your column to have a Z, then I would suggest changing your table.

By

a) update existing column using

ALTER TABLE network.VEJM_BR_SL 
  ALTER COLUMN geom TYPE geometry(LINESTRING,4326) USING ST_Force2D(geom) ;  

or

b) Add a new 2D column

ALTER TABLE network.VEJM_BR_SL ADD COLUMN geom_2d geometry(LINESTRING,4326);
UPDATE network.VEJM_BR_SL SET geom_2d = ST_Force2D(geom);

I should also add that if your tables are mixed case names, not all lowercase, you should probably change them to lowercase to save yourself some grief down the road of having to always "" quote them.

For the above I assumed your srid is 4326 - change it to whatever yours is currently.

If you go with plan b, then pass in 'geom_2d' for the column name.

0

SELECT pgr_createTopology('network.VEJM_BR_SL', 0.001, ST_Force2D(geom), 'id');

Try running the query without quotes around geom.

  • thanks for your reply! But then I get an error: "column "geom" does not exist" – Lars Christensen Mar 16 '15 at 14:04
  • Well then your geometry column is not called geom. – Michal Zimmermann Mar 16 '15 at 14:40

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.