[GIS] How to set the tolerance value in pgr_createTopology function of pgrouting

pgroutingpostgresqltopology

I am making a map based on the floor plan of a building.
I made the shapefile and added it to the PostgreSQL database.

I created the topology for the map using the following code:

SELECT pgr_createTopology('ways', 0.00001, 'the_geom', 'gid');

The tolerance provided here is 0.00001. I didn't get many vertices when I checked it up (just 14). How can I set a proper tolerance value? What does it depend on?

Best Answer

The tolerance value is in the same unit as your geometry. When the distance between start/end point of two linestring geometries is smaller than the tolerance, then the topology function assumes, that these two points are connected. This means, both points get snapped together.

The unit of the tolerance value is in most cases either meter or degree, which usually makes a big difference.

In your case, if the projection unit would be meter, then 2 points must be very very close to make a connection between the road segments.