Linear Referencing (Plugin-Release 2.1.0)

QGis-Plugin to support measurement of points/segments on reference-lines and recording of linear referenced data.

Contents

Principle of linear referencing

"Normal" vector layers store geometrys using numerical coordinates (depending on the geometry type, single points or sequences of points with X/Y coordinates).

"Linearly referenced" layers use numerical stations (points or segments) on associated line geometrys.

Referentable geometry types

Points (hereinafter referred to as "PoL", Point-on-Line) or sections (hereinafter referred to as "LoL", Line-on-Line) on lines can be referenced.
PoL
Point geometrys using line assignment and numerical stationing, e.g. structures on a body of water:
LoL
Line segments using line assignment, two stationings (From...To) and a distance to the line, e.g. sections along a body of water:

Required layers

The plugin uses three layers for recording and displaying linearly referenced geodata:
Reference-Layer
Base layer on whose line geometrys the linearly referenced data sets are numerically positioned.
  • Vectorlayer
  • all QGis-supported formats (GeoPackage, SQLite, SpatiaLite, Shape, Geo-Database...)
  • Type (Multi-)LineString(-ZM)
  • uniqe ID-Field (usually Primary Key)
  • unified digitization direction
Data-Layer
Stores the linearly referenced data records by assignment to reference layer and stationings.
  • usually geometry-less vector-layer
  • alle QGis-supported formats (dBase, GeoPackage, SQLite, SpatiaLite, Database, temporary memory-layer)
  • on or three numerical fields (PoL: stationing, LoL: stationing-from/to + offset) (Von...Bis) und ein Offset-Field (LoL)
  • Join-field to Reference-Layer (same type)
Show-Layer
Cartographic representation of the linearly referenced datasets.
  • Vectorlayer, geometrytype point (PoL) or line (LoL)
  • Joins Reference- and Data-Layer (SQL)
  • virtual layer (SQL with SpatiaLite, possibly poor performance with large datasets...)
  • alternatively external calculated vector layer (f. E. PostGIS-View) or exported virtual layer
  • Same projection as reference-layer

"LR-Mode"

Positioning a point on a reference line can be done in several ways.
Nabs
absolute running distance to the starting point
Advantages:
  • Easy to understand, easy to measure, easy to verify
  • easy numerical editing (f. E. shift all sections by a constant amount)
  • simple caclulations, f. E. segment-length = from...to-stationing-difference
Disadvantages:
  • Projection-dependent: calculated positions depend on calculated lengths; in case of reprojection, the stationing must be corrected.
  • The maximum value of the stationing (= caclulated total length of referenced geometry) must be adhered, shortening the reference line can "cut off" linearly referenced geometries at the end.
  • Changes to the reference geometry affect the linearly referenced geometries differently depending on their position:
    • Changes after the referenced geometries have no impact
    • Changes before the referenced geometries will shift these to the extent of the change in length
Nfract
Positioning relatively to the length of the referenced line (0...1)
Advantages:
  • simple validation (range allways 0...1)
  • not projection-dependent
Disadvantages:
  • Cannot be verified by simply measuring in GIS/Nature.
  • Changes of reference-geometry will impact all relatively referenced points/segmente
  • difficult calculation of absolute distance between points
Mabs
Uses Vertex-M-Values, an additional numerical value for each vertex
Advantages:
  • quite insensitive against reference-geometry-edits: only linear referenced geometries in the area of reference-geometry-edits are affected
  • stationings independend from length specifications (f. E. stationings using timestamps from GPS-routes)
  • insensitive against projections (f. E. usage of metric stationings as Vertex-M-Value in a WGS-84-reference-layer)
  • Areas with compressed/stretched positionings possible
  • Stationings with offsets, f.e. divided reference-geometries at border crossings (with continuing M-Values) or rivers with very wide junction areas (virtual axis beginning at intersection, first vertices with negative M-values, only from intersection of the shorelines M-values >= 0)
Disadvantages:
  • Cannot be verified by simply measuring in GIS/Nature.
  • geometry-type with additional requirements (single-parted, monotone ascending M-values, see ST_IsValidTrajectory)
  • Additional requirements for geometry edits in reference-layer, beside X/Y-coordinates valid vertex-M-values must be recorded (f. E. via vertex-editor). F. E. an inserted vertex with invalid (not ascending) M-value makes the reference-geometry unsuitable and all assigned linear referenced features invalid.
  • complicated positioning of linear referenced features, depending on visible X/Y-coordinates and invisible M-values.
  • numerical editing ("shift all points 10m") impossible
  • complicated (absolute) distance calulations between linear referenced points
Conversion:

A subsequent change to the LR mode is possible, but requires the conversion of existing stationings.

This can be done with field-calculater, alternatively with python-script:
2025-12-03 LR-Convert.txt:
  1. create backup of the data layer
  2. load script to python console
  3. adapt layer- and field-names
  4. run the script...

Usage

Remarks

  • The plugin is controlled by independend settings and dialogs (PoL/LoL), which can be called from toolbar:
    or menu:
  • Some dialog-contents are dependent on situation and runtime environment f. E. depending on Reference-Layer-Type:
Standard-Icons
(used in both dialogs with the same functionality)
  • Access associated help page
  • dock/undock dialog
  • Open attribute-form
  • Open attribute-table
  • zoom/highlight feature
  • select feature in layer

Measurement, Recording

For measurement only the registration of a suitable reference layer (LineString) is required.

PoL
  1. Click on dialog-button to start measurement
  2. moving the mouse on reference-geometries will already show measurements.
  3. With a click on desired position on reference-feature measurement is finished, the results are displayed and fixed in dialog, some function-icons for processing the linear referenced geometry are enabled.
LoL
Measurement is done with mouse-down (startpoint), mouse-move und mouse-up (endppoint) on a feature of reference-layer:
Recording
Saving new or editing existing linearly referenced features can be done using QGIS built-in tools (numeric data entry in tables/forms...) and/or plugin-supported:
Insert-procedure:
  1. finish measurement (alternatively use existing feature as template)
  2. edit stationings if necessary (interactive, function-icons, numerical inputs...)
  3. insert Feature (opens attribute-form with currently displayed stationings)
Update-procedure
  1. select existing feature (single-feature from map , from Feature-Selection or via Layer-Actions from feature-table/form)
  2. edit stationings (interactive, function-icons, numerical inputs...)
  3. save feature (opens attribute-form of selected feature, but using currently displayed stationings)

Feature-Selection

User-definable selection of records for visualization and editing.

Selection can be done on map , from attribute-tables/forms (Data-layer/Show-layer) (see Layer-Actions) or using .

Plugin-recorded features are also included.

Validation-problems (f. E. stationings out of bounds, missing reference-features...) are symbolized in treeview with according hints.

PostProcessing

Edits of a referenced geometry may impact the assigend linear referenced geometries dependend on
  • kind of geometry-edit (geometry-move, vertices moved/added/removed, vertex-M-value changed)
  • the relative position of the geometry change (befor/behind/in the area of to the referenced points/segments)
  • the chosen LR-mode

"PostProcessing" allows the combination of Data-Layer with an alternative reference-layer-version (must have same geometry-type, projection, reference-ids as reference-layer). As result all records are with affected linear referenced geometries are listed.

From this list the two versions can be cartographically contrasted und stationings adjusted.

Process
Variant 1: Data- and reference-layer edited within the same project
  1. If necessary: Create and/or register a backup-version with the original geometries in PostProcessing-settings
  2. Perform geometry editing in reference layer
  3. Start PostProcessing, which will identify the altered reference-geometries and the affected linear referenced geometries
  4. PostProcess stationings
Variant 2: new version of referenz-layers (f. E. externally edited)
  1. register the new layer and ID-field in settings, create new show-layer
  2. register previous version in PostProcessing-Settings as Compare-Reference-Layer
  3. Start PostProcessing, which will identify the altered reference-geometries and the affected linear referenced geometries
  4. PostProcess stationings
PoL-result: LoL-result:

Settings

Base for all usages is the "Reference-Layer", for recording a "Data-Layer" is necessary, for cartographic representation a "Show-Layer".

PoL
LoL

Miscellaneous

Message-Log

System-messages, errors, debug-metas (file/line/function/backtrace as tooltip)

Layer-Actions
The registered layers will have some layer-actions in their attribute-forms and tables:
Snapping

The configurable snap-settings under Settings/Miscellaneous are a subset of QGis-Advanced-Snap-Settings and applied to reference-layer.

With each use of one of the plugin-maptools these settings will replace any other snap-settings in the current project.

Impressum

Author:

Ludwig Kniprath

Mailto:

ludwig[at]kni-online.de

Plugin-Version:

2.1.0 (2026-01)

Plugin-Download:

LinearReferencing

Source-Code und Tracker:

https://github.com/Ludwig-K/QGisLinearReference/

Lizenz:

GNU General Public License v3.0

Toc