Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to clean a shapefile to make it usable for routing with pgrouting, postgis, postgresql.

Here an intersection, it seems to be connected but when we zoom …. It is not:

not zoomed 1 zoomed 1

Same here :

not zoomed 2 zoomed 2

Here (it is zoomed at max) there is 2 ways when it seems to be one, and only one is connected :

zoomed at max 2

I am using assign_vertex_id with different tolerances. And QGis and postgis but I don't know what to use in it. Thanks.

share|improve this question
I wonder: are these truly errors? For instance, both situations could be used to represent a two-way street meeting a one-way street. This may be a critical issue, because you don't want to introduce new errors in an effort to eliminate others! – whuber Aug 1 '11 at 22:05
In fact it is just an horribly bad shapefile, I want an extremely simple undirected routing, and what you see is very zoomed. – hokkos Aug 3 '11 at 8:57
up vote 10 down vote accepted

You can use GRASS to do some cleaning. I think you need to break those vectors remove duplicates and then snap them. For that there is the v.clean tool with the options break, rmdupl and snap .

share|improve this answer

Within PostGIS, try ST_SnapToGrid to snap vertices to a virtual grid. You need to to some detective work to determine what snapping distance to use. It could be a 0.01 (1 cm), or 1.0, etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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