This script measures the overlap between two lines by clipping the overlap and returning a line layer with a length field. It first snaps the two lines, clips the overlap, dissolves it, and adds a length field in meters.
There is no native tool that does this in QGIS if I'm not mistaken.
The tool is NOT made from scratch and can be made using the Graphical Modeler. However, this script was tweaked a bit to organize the forms and add more functionality soon.
This started from a task at work that required measuring the overlap between two transport routes. I didn't find any tool that did this and the only way to do it was to manually measure. I made a short PyQGIS script and then converted into a processing plugin later on.
Notice that the resulting layer is snapped completely to the reference layer. Snapping is needed before clipping to ensure the entire overlap is clipped and measured.
- The resulting layer should be named as "Overlap between
name of line 1
andname of line 2
" - the default
length
field should be namedlength_km
and divide the value with 1000 to get the length in kilometers, - and add two fields named
ovp_perc1
andovp_perc2
which shows the overlap in percentage versus line 1 and line 2, respectively.