Skip to content

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.

Notifications You must be signed in to change notification settings

miguel123-gis/calculate-lines-overlap

Repository files navigation

Measure route overlap processing plugin in QGIS

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.

1. Situation

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. image

2. Screenshot of the processing plugin

image

3. Result layer

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. image

4. Attribute table

image

5. Improvements needed

  1. The resulting layer should be named as "Overlap between name of line 1 and name of line 2"
  2. the default length field should be named length_km and divide the value with 1000 to get the length in kilometers,
  3. and add two fields named ovp_perc1 and ovp_perc2 which shows the overlap in percentage versus line 1 and line 2, respectively.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages