1

We are trying to make a network topology for pgRouting from our own data. But there is a problem we could not resolve; our road data look like this;

enter image description here

The red edge is a single geometry, so we can not make a route between these nodes. How can we convert this data to be able to make routing work?

  • You mention pgrouting but don't specify if you're using PostGIS, QGIS, or something else. The basic problem is there's no connectivity between the two segments. This is due to one (or both) of two things: 1) the end of the purple line is not snapped to a vertex of the red line, 2) the connectivity policy for the network (if there is such in pgrouting, I'm coming from an ArcGIS network background here) is set to only allow connection at end nodes and not any vertex. Planarizing the lines may fix it (and also may break other things where connections shouldn't happen like overpasses). – Chris W Apr 6 '15 at 7:33
3

You can use the pgRouting function pgr_nodeNetwork, which will create nodes at intersections of linestrings.

So in your case it will split the linestring into two geometries. But there is a danger that intersections, that should not be connected (ie. over- or under-passes), will also get broken into two segments.

  • Thank you, I tried this. After processing for about 5 minutes (table has 2300 rows), it gives this error; ERROR: line_locate_point: 1st arg isnt a line CONTEXT: SQL statement "create temp table inter_loc on commit drop as ( select * from ( (select l1id, l2id, st_linelocatepoint(line,source) as locus from intergeom) union (select l1id, l2id, st_linelocatepoint(line,target) as locus from intergeom)) as foo where locus<>0 and locus<>1)" – muhalif Apr 6 '15 at 8:49
  • I guess the problem is that the geom column's type is MultiLineString. But I cant convert it to LineString because I have some rows which has multiple geometries. (ST_NumGeometries(geom) > 1) – muhalif Apr 6 '15 at 9:04
  • 1
    With multilinestrings pgRouting will not work correctly. Because there is only a single source and target attribute and you will get strange results as pgRouting will only take the first linestring of the multilinestring record. See gis.stackexchange.com/questions/116414/… – dkastl Apr 6 '15 at 12:25
  • 1
    You can use ST_Dump to convert your MultiLineStrings into linestrings. postgis.net/docs/manual-2.1/ST_Dump.html – LR1234567 Apr 6 '15 at 17:12
0

Before applying pgrouting to your data, you have to turn your data into Network. By network I mean topological network where all rules are taken care of and there is no violation of the network rules.

I am sure you know little about the topological rules. For example there must be a end node where your link is touching the red link in the above picture.

You can remove such errors in QGIS with a plugin called PostGIS Topology Editor.

First apply topology rules, then try to implement PgRouting.

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.