1

In QGIS 3.6 I have been trying to find intersections between two line shapefiles (roads and telecom cables). I've only been able to extract the lines where there is an intersection using the "Extract by Location".

I want the result to appear in a another shapefile where I already created a field for intersection (1 or 0). Any idea how to achieve this?

3

Using the following expression via the Field Calculator may provide the desired output. As was mentioned here:

The field calculator is very useful when used in The graphical modeler.

For QGIS 3.16 and higher versions

0 + overlay_intersects('lines_test')

For QGIS 3.10 and higher versions

intersects($geometry,
           collect_geometries(
                array_foreach(
                        generate_series(0, layer_property('lines_test','feature_count')-1),
                        geometry(get_feature_by_id('lines_test', @element))
                        )
                    )
    )

Above expressions will result either in 0 or 1

P.S. 'lines_test' is a name of another polyline layer

1

First export your existing ends then split your lines at their intersections from the split lines export the revised endpoints, select from these new endpoints the ones that match the previous (original) endpoints using select by location and remove them, this will leave you with the new points only i.e. the intersection location but there may be multiple points exactly on top of each other which you can resolve by buffering by a small amount with a dissolve.

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.