0

I am not very experienced in QGIS as I have been working on it only as a student. My question has to do with ID matching. I have a line shapefile, which represents roads (polyline tbh), and I have found for every "edge" of my graph, x_start, y_start, x_end, y_end by using the xat(0), yat(0) etc function. I have also made a new point shapefile containing the intersections, which should be the nodes of my graph, and this layer has also x, y calculated. Although it seems so simple, I cannot give the correct IDs to the line layer. I.e. edge 33 is between nodes 11 and 26 for example. What I want is to "join" the nodes with the correct ID to their containing edge.

I tried to join by attributes 2 times. At first I used as keys the "x_start" of line layer, along with "x" of the point layer, and after that did the same using this time "x_end" of line layer" along with "x" of the point layer. The problem is that, as you 'd expect, the 2 shapefiles don't contain the same number of features (the edges are more). As a result, result is correct for about a 60-70% of my network. Is there any solution for this? Hope that I was clear on what my problem is.

I had previously tried to use the "exact specific vertices" tool in the line layer using 0 and -1, but didn't help because the id numbering was not correct.

I have to note that I've checked that there aren't duplicate nodes or lines, as this would be a problem.

In an even simpler way, what I want is every unique (X,Y) couple to be matched with its unique ID, either found as an endpoint node or as a startpoint node. And I have'nt found a way to do this correctly. I just want the correct ID correspondence, because I am going to use the vertices as origins afterwards in python in order to find some shortest paths, and it must be clear which edges originate from each node, and simultaneously, which edge is contained between every couple of nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.