This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to find dead end roads

3

I am developing a sampling technique to do quality assurance checks. One of the things I need for the technique is to find the amount of dead end roads in a certain area. How can this be achieved? I have looked at using JOSM and Overpass-Turbo but I haven't been successful so far. Any help would be appreciated.

asked 14 Jul '15, 10:45

BmanS's gravatar image

BmanS
56447
accept rate: 0%


3 Answers:

2

You could load the road network data into QGIS and then find dangles

answered 14 Jul '15, 15:18

joost%20schouppe's gravatar image

joost schouppe
3.4k245087
accept rate: 12%

Would also be possible, in QGIS, to find roads that intersect but have no node meaning there is no junction between the roads? and to find all the unnamed roads?

(14 Jul '15, 20:53) BmanS

Unnamed roads would be straightforward: you could open the attribute table and select roads with an empty name column. Or you can do the same with a simple query. It would require converting your osm data to a format with a limited number of attributes (like for example a shapefile). I'm not sure on the details of finding the missing nodes, but it will probably not be that hard with the "intersect" tool. If you get that far, ask at e.g. gis.stackexchange.com

(15 Jul '15, 07:13) joost schouppe

2

When you load data into GraphHopper you can use the following Java snippet to calculate all coordinates of dead ends in the whole area and do further analysis:

    CmdArgs args = CmdArgs.read(strs);
    GraphHopper hopper = new GraphHopper().init(args);
    hopper.importOrLoad();
    Graph graph = hopper.getGraph();
    NodeAccess nodeAccess = graph.getNodeAccess();
    AllEdgesIterator iter = graph.getAllEdges();
    EdgeExplorer explorer = graph.createEdgeExplorer();
    List<GHPoint> deadEndPoints = new ArrayList<>();
    while (iter.next())
    {
        int node = iter.getAdjNode();

        // an edge is a connection from junction to junction
        // so if you count all edges from a certain junction
        // and it is exactly 1 you have found a dead end
        if (GHUtility.count(explorer.setBaseNode(node)) == 1)
        {
            deadEndPoints.add(new GHPoint(nodeAccess.getLat(node), nodeAccess.getLon(node)));
        }
        node = iter.getBaseNode();
        if (GHUtility.count(explorer.setBaseNode(node)) == 1)
        {
            deadEndPoints.add(new GHPoint(nodeAccess.getLat(node), nodeAccess.getLon(node)));
        }
    }
    System.out.println(deadEndPoints);
    hopper.close();

answered 23 Jul '15, 10:21

peatar's gravatar image

peatar
3512312
accept rate: 8%

0

The pgsnapshot schema from osmosis should be able to help here. You get a SQL version of the OSM data model, and can write SQL queries to find nodes that are only at the start or end of an OSM way with the tags that you want.

answered 14 Jul '15, 11:15

rorym's gravatar image

rorym
5.4k1449100
accept rate: 11%

Source code available on GitHub .