# Calculating distance between matching intersections using QGIS?

I have a streetmap with the coordinates of some speed limit signs (which mark either the beginning or the ending of a speed limit and hold the applicable speed limit in km/h). With regard to the direction of driving, the signs are always positioned on the right side of the road: What I want to do now is to create a new line layer which shows the speed sections (the length in km of the speed section and the speed limit in km/h itself).

As you can see the red rectangle in the image above, I will cover the marked area in an example: In order to do that, I guess I will have to create normal vectors with the points of the speed signs and the streets itself in order to get intersections directly on the streetline. I know how to do that by now. But how can I "drive" along the streetline to sequentially check each speed sign in order to extract the speed sections? Let's take the picture above as an example: If I start south at the beginning of the 70 km/h speedsection, I have to drive north (because it is the driving direction of the street) and check each speed sign along the line for the end of the speed section. After that, I search for the next beginning speed section and so on.

How can that be realized? Please comment if you need more details on that issue.

This is just about how to check the speed value from the speed sign nearby the start point of each section.

• Please assume your road section is a polyline from node 0 to node n. Here n=4 on the below, red arrow example (driving northeast then north).
• And a point layer `speed_signs` has `speed` field.
• The driving azimuth at the start point (node 0) "A" is given by `angle_at_vertex( \$geometry, vertex:=0 )` this is a clockwise angle starting from north.
• From the start point, the speed post (40 km/h) should be on the right hand side, its direction (from the start point) "B" is ```azimuth(start_point(\$geometry), geomnearest(‘speed_signs’, ‘\$geometry’)) ``` (please note `geomnearest()` function is from refFunction plugin). Probably `degrees()` is required to convert the radians to degrees.
• To avoid another nearby speed sign (on the opposite side; 30 km/h), the angle between the road and the speed post (`B - A`) has to be less than 180 degrees. Conditional statement something like `CASE WHEN (B - A) < 180 THEN...` would be useful.
• Then the speed data can be taken, again by using refFunction `geomnearest('speed_signs', 'speed')`. • I do not quite understand how the speed post (40km/h for instance) can have a direction? Same here with the nodes. what if a node is located directly on a crossroad? What will my direction then be? I am trying to calculate the speed sections of a whole streetnet - with speed posts located all around. In which way can I realize this then? – applebrown Mar 16 '18 at 15:49
• @applebrown Please edit your question and add scenarios you want to be covered by potential answers. I think I have answered for the case you have described in your original post. – Kazuhito Mar 16 '18 at 19:10
• edited my question and it is more detailed now! :) – applebrown Mar 21 '18 at 8:34