L-RAT is a QGIS Processing plugin focused on road engineering and linear-infrastructure workflows. It includes tools for:
- Calibration (Chainage/PK): add/derive chainage values (PK) in geometries (compute chainage point by proximity; generate/adjust M values on lines).
- Linear referencing (Chainage/PK): locate and extract points and segments along calibrated lines (
LineStringM / MultiLineStringM). - Profiles & slopes: compute longitudinal profile and slopes from an axis and a DEM, and generate plots/outputs for mapping (no chainage/PK needed).
- Misc: geometric analysis on linear layers (e.g., curve detection and curvature centers).
Repository: https://github.com/Javisionario/L-RAT
Linear geometries
LineString/MultiLineStringLineStringM/MultiLineStringM(lines with an M value per vertex)- Optional
Z(preserved when applicable)
Point geometries
Point/MultiPoint(events, milestones, samples)
Recommended CRS
- For measurements and distances: a projected CRS (meters).
LineStringM / MultiLineStringM layers store, in addition to X/Y (and optionally Z), an M value per vertex. In road contexts, M is commonly used as kilometer point / chainage (PK), enabling you to:
- Interpolate a position along a line from a chainage value (PK).
- Extract segments between a chainage start and end.
- Calibrate points by proximity to an M-enabled network.
L-RAT provides tools to perform these workflows.
L-RAT algorithms include M unit parameters (meters or kilometers).
An incorrect configuration will produce wrong results (e.g., shifted points or inconsistent lengths).
Many algorithms work per route/road using an identifier (typically ROUTE_ID):
- A linear layer (axis/road centerline) with
ROUTE_ID. - An events layer/table (points or segments) referencing the same
ROUTE_ID.
If a road is split into multiple features, L-RAT can:
- work per feature, or
- group by ROUTE_ID (when the option exists), keeping global consistency.
In dense networks or with parallel roads, restricting by ROUTE_ID is often essential to avoid wrong matches.
L-RAT tries to be flexible with PK input and accepts common formats:
km+mmm(e.g.,12+345)- decimal kilometers (e.g.,
12.345,3,05) - PK in meters (depending on algorithm and unit options)
L-RAT can log issues to audit adjustments, warnings, and errors:
- in output fields (e.g.,
ADJUSTED,ADJUST_REASON,STATUS), - in an optional issues table (created only if enabled and if issues exist),
- and in the Processing log.
NOTE: Details (exact fields and codes) are documented per subgroup in 4.1 / 5.1 / 6.1, because they differ slightly between algorithm families.
- From the official QGIS plugin repository (recommended): when published, install it via QGIS → Plugins → Manage and Install Plugins → All → search for
L-RAT. - From ZIP/GitHub (development):
- Download the repository ZIP.
- QGIS → Plugins → Manage and Install Plugins → Install from ZIP → select the downloaded ZIP.
Algorithms appear in the Processing Toolbox under these subgroups:
- Calibrate M Geometry
- Locate points (requires M geometry)
- Locate segments (requires M geometry)
- Miscellaneous
- Profile & Slope
This subgroup provides tools to calibrate chainage (PK) values to prepare data for linear-referencing workflows. These algorithms add or edit calibration values on existing geometries.
In this subgroup, traceability relies on control fields in outputs and, in some algorithms, an optional issues table.
Traceability mechanisms (depending on the algorithm):
-
Line output with
STATUS(string):- Calibrate lines from distance
- Calibrate lines from points (events)
- Modify M geometry
-
Point output with
INCIDENCE(0/1) +INC_TYPE(string):- Calibrate points
-
Optional issues table (
OUTPUT_ISSUES, no geometry) (only for some algorithms):- Calibrate lines from points (events)
- Calibrate points
The issues table is created only if the user enables the option and there are actual issue rows.
Typical behavior when issues occur:
- Line algorithms usually return one output feature per input feature. If calibration cannot be done correctly,
STATUSdescribes the reason and control fields may beNULL. - In Calibrate points, every point is always present in the final layer, but:
INCIDENCE = 1indicates an issue,INC_TYPEidentifies the reason,- some fields (
PK,M,DIST_AXIS) may beNULLdepending on the case.
Calibrates the M value of a line layer based on cumulative distance from an origin. The result is a calibrated LineStringM / MultiLineStringM layer (preserving Z if present), calibrated by distance from origin (per feature or per route).
- Line layer to calibrate (with or without M).
- M units (output):
Meters (m)/Kilometers (km). - Start M value: initial M value (in output units).
- Reverse direction: M decreases along the geometry direction.
- Overwrite existing M: if disabled and geometry already has M, it is skipped and flagged in
STATUS. - (Advanced) Length mode:
Auto,Planar,Geodesic(use a local projected CRS).Auto(recommended): uses planar distances if CRS is projected; if CRS is geographic, uses a local projected CRS to measure/locate.Planar: forces planar distances in the layer CRS.Geodesic: forces calculations using a local projected CRS.
- Calibrated lines (
LineStringM/MultiLineStringM). - Added fields (in addition to original fields):
M_START(double)M_END(double)LEN_M(double) — length in M units (per configuration)STATUS(string)N_SEGS(integer) — number of segments/parts in the original feature. Recommended to verify calibration continuity (M values) whenN_SEGS > 1(MultiLineString geometries).
STATUS can take the following values:
OK: calibrated successfully.SKIPPED_HAS_M: not recalibrated because it already had M and Overwrite existing M is disabled.BAD_GEOMETRY: empty/invalid/non-linear geometry.ZERO_LENGTH: length 0 (warning).NO_REFERENCE_GEOM: failed to build/get a valid reference geometry for that route (route mode only).
Note: If the input geometry is multipart (MultiLineString), each part is processed separately and the output will contain one feature per part.
Calibrates the M field of a line layer with chainage (PK) stored in a points/events layer.
Each point is projected onto the nearest line (or onto the corresponding route if restricted by ROUTE_ID) and used as a control point to interpolate and assign M along the axis. The result is a LineStringM / MultiLineStringM layer calibrated with M values according to the provided chainage (PK).
- Line layer (with or without M): linear layer to calibrate (with or without existing M values).
- Reference point layer: events with known chainage (PK) values.
- Chainage (PK) field: field containing those values.
- Input chainage (PK) units (point field):
Auto ('PK+mmm' text or infer units: m / km)Meters (m)Kilometers (km)
- M units (output):
Meters (m)/Kilometers (km) - Maximum distance (search / projection)
Maximum threshold to accept point–line matching. If the closest match is farther than this, the point is flagged as an issue (TOO_FAR) and does not contribute to calibration. - Endpoint snap tolerance (to build route reference)
Tolerance used while building theROUTE_IDreference (when grouping by route).
-
Group by ROUTE_ID: (Requires specifying the
ROUTE_IDfield in both points and lines). Forces each point to calibrate only the line with the same route identifier. Also, the algorithm automatically detects forks and parallel centerlines and generateswarningsif they may affect calibration. -
Add ROUTE_ID to output (from points): if output already has
ROUTE_ID, createsROUTE_ID_FROM_PTSto avoid overwriting. -
Behavior outside control range:
Linear extrapolation: extends linearly using the slope from the extreme controls.Clamp: fixes M to the nearest extreme control value (flat/constant outside range).Leave NULL (NaN): leaves M unassigned outside the range (NULL/NaN), useful to identify uncalibrated parts.
-
(Advanced) Factor:
M_final = M * factor -
(Advanced) Offset:
M_final = M + offset -
(Advanced) Generate issues table: created only if enabled and issues exist.
-
(Advanced) Generate projected points: to inspect projected point positions vs the input layer.
Note on forks/parallel segments: the algorithm detects potentially ambiguous geometries and emits warnings for review.
- Calibrated lines (
LineStringM / MultiLineStringM)
Added fields (in addition to original fields):- (Optional, if “Add ROUTE_ID to output” enabled)
ROUTE_IDorROUTE_ID_FROM_PTS(string) N_CTRL(int) — number of controls finally used for that feature (after filters)M_START(double) — M at first vertex (can beNULLif NaN at start)M_END(double) — M at last vertex (can beNULLif NaN at end)M_LEN(double) —abs(M_END - M_START)if both exist; otherwiseNULLLEN_GEOM(double) — geometric line length (in CRS units)LEN_ERR_M(double) —abs(LEN_GEOM - M_LEN_in_meters)ifM_LENexistsLEN_ERR_P(double) — percent error vsLEN_GEOMifM_LENexists andLEN_GEOM>0HAS_NULLM(int) — 1 if any vertex ended with M =NaN(when “Leave NULL” outside range)STATUS(string)N_SEGS(integer) — number of segments/parts in the original feature. Recommended to verify calibration continuity (M values) whenN_SEGS > 1(MultiLineString geometries).
- (Optional, if “Add ROUTE_ID to output” enabled)
Note:
LEN_GEOM(and thereforeLEN_ERR_M/LEN_ERR_P) is meaningful only in a projected CRS (meters). In a geographic CRS (degrees) these values are not comparable.
-
Projected points (optional, if enabled)
Fields:PT_ID(string)LINE_FID(int)ROUTE_ID_LINE(string)ROUTE_ID_PTS(string)PK_RAW(string)M(double)DIST_AXIS(double)DIST_ALONG(double)
-
Issues (table) (optional, if enabled and has rows)
Fields:INC_TYPE(string)PT_ID(string)ROUTE_ID(string)PK_RAW(string)LINE_FID(int)DIST_AXIS(double)DIST_ALONG(double)NOTE(string)
OK: calibrated successfully.BAD_GEOMETRY: invalid or inconsistent geometry during processing.NO_ROUTE_REFERENCE: failed to build a valid route reference (ROUTE_ID mode).INSUFFICIENT_POINTS: not enough valid controls to calibrate that feature/route.
- Typical point-related issues (critical for that point):
BAD_GEOMETRY: invalid/empty/non-point geometry.PK_INVALID: PK could not be parsed/converted.NO_ROUTE: missingROUTE_IDon point or not present in lines (if route restriction enabled).TOO_FAR: a candidate line exists, but the closest exceedsMax distance.NO_MATCH: failed to obtain a valid match.INSUFFICIENT_POINTS: not enough valid controls to calibrate the route/feature.NO_ROUTE_REFERENCE: failed to build a valid reference for the route (group byROUTE_ID).
- Quality-review warnings:
DUPLICATE_POS_IGNORED: multiple PKs project to the same position on the reference → duplicates ignored.NON_MONOTONIC_PK: PKs do not follow spatial order along the axis (possible PK or matching error).ROUTE_TOPOLOGY_WARNING: route reference shows suspicious topology (gaps/order) and should be reviewed.
Assigns a chainage value (PK) to each point from the interpolated M value, by projecting the point onto a calibrated line layer (LineStringM / MultiLineStringM). It does not change point geometry: it adds calibration fields to attributes.
- Point layer to calibrate
- Calibrated line layer (M)
- M units: m or km
- Maximum distance (search/projection): threshold to accept matching (if the nearest axis is farther, an issue is flagged)
- Restrict matching by ROUTE_ID (requires
ROUTE_IDin points and lines)
Searches only within the same route/road. (Recommended if there are parallel roads.) - Add ROUTE_ID to output (from lines) (if it already exists, creates
ROUTE_ID_MATCH)
Copies the matched line identifier to the point. - Generate issues table (only if any) (advanced)
- Calibrated points (original attributes +)
- (Optional if enabled)
ROUTE_IDorROUTE_ID_MATCH(string) PK(string) — chainage formatted askm+mmmM(double)DIST_AXIS(double)INCIDENCE(int) — 0/1INC_TYPE(string)
- Issues (table) (optional)
Fields:PT_ID,ROUTE_ID,PK,M,DIST_AXIS,INC_TYPE
BAD_GEOMETRY: empty/invalid/non-point geometry.NO_ROUTE: missingROUTE_IDor not present in the line layer (if restricted by route).NO_M_VALUES: no usable M values found in candidate lines.TOO_FAR: a projection with M exists, but exceeds max distance.NO_MATCH: failed to obtain a final valid projection.
Modifies existing M values in a LineStringM / MultiLineStringM layer using common recalibration operations.
It does not change X/Y (or Z); it only rewrites M.
Intended for:
- Fixing calibration errors
- Converting units
- Reversing chainage direction
- Normalizing origins
- Cleaning small “bounces” in M values
- Line layer with M (
LineStringM / MultiLineStringM)
Operations are applied in this general order: Factor/Offset → Reverse → Set origin → Clamp → Monotonicity.
- Offset: shift all M values by a constant:
M' = M + offset - Factor: scale all M values. Useful for unit conversion or recalibration (e.g., km ↔ m):
M' = M * factor - Reverse M (preserving range): reverse direction without changing the range:
M' = (Mmin + Mmax) − M - Set origin (TARGET_START): apply a uniform shift so the first vertex matches the target M, keeping consistency from
TARGET_START - Clamp to [min, max]: limit M to a min/max range. Useful to clean out-of-range values without “remapping” calibration (does not compress/stretch). May create flat segments at start/end.
- Force monotonicity: fix “bounces” so M is always increasing or decreasing (with
epsilon)
- Require M (advanced): if enabled, geometries without M are flagged with
STATUS=NO_M_VALUES. If not required, they are skipped withSTATUS=SKIPPED_NO_M.
- Per feature (recommended): operations use each feature’s own range/origin.
- Per ROUTE_ID (requires
ROUTE_ID): uses a common range/origin across multiple features (useful for split routes).
- Layer with modified M +
STATUSOK: modified successfully (or no change needed).SKIPPED_NO_M: feature has no M; skipped (if M not required).NO_M_VALUES: no usable M values found to operate (includes no-M cases).BAD_GEOMETRY: invalid/non-linear geometry.NO_ROUTE: missing validROUTE_ID(if scope is per route).
This subgroup locates (interpolates) points along an M-calibrated network/axis with valid M values (LineStringM / MultiLineStringM) from ROUTE_ID + chainage/PK.
- Calibrated line layer (
LineStringM / MultiLineStringM): network/axis with M values. - ROUTE_ID field: route index field
ROUTE_ID(string). - M units (km or m)
Common advanced options:
- Tolerance (km): fixes small mismatches within calibrated coverage (rounding or imperfect calibration). Does not fix coverage discontinuities; it only helps when chainage (PK) falls very close to an existing/interpolable value.
- Adjust to nearest available chainage point (PK): controls what happens when the chainage (PK) falls into an M-coverage discontinuity (due to incomplete geometry or M gaps):
- Enabled → the point can be created by snapping to the nearest covered chainage (PK) (
ADJUST_REASON=GAP_SNAP). - Disabled → the event becomes critical (
NO_MATCH) and the point is not created.
- Enabled → the point can be created by snapping to the nearest covered chainage (PK) (
- Generate issues table (adjustments/critical)
If enabled, the table is created only if there are actual issue rows (adjustments or critical events).
Traceability in this subgroup is based on:
- Control fields in point outputs:
PK_REQ,PK,ADJUSTED,ADJUST_REASON,STATUS. - An optional Issues (table) with fields:
ADJUSTED,ADJUST_REASON,WARNINGS,CRITICALS.
PK_REQ: requested chainage (PK) (formattedkm+mmm).PK: final chainage (PK) used (may be adjusted).ADJUSTED:0/1.ADJUST_REASON: reasons separated by;(e.g.,OUT_OF_RANGE;GAP_SNAP).STATUS: for generated points, the algorithm writesOK.
- Created only if enabled and there are actual rows (adjustments and/or criticals).
- Records:
- Adjustments: row with
ADJUSTED=1,ADJUST_REASON=...,CRITICALSempty. - Criticals: row with
CRITICALSfilled (e.g.,NO_ROUTE,PK_INVALID,NO_M_RANGE,NO_MATCH).
- Adjustments: row with
OUT_OF_RANGE
Requested chainage (PK) is outside the route’s global[M_min, M_max]range and is clamped to the nearest endpoint.GAP_SNAP
Requested chainage (PK) falls inside the global range but in an M-coverage discontinuity; if adjustment is enabled, it snaps to the nearest covered PK.
NO_ROUTE:ROUTE_IDdoes not exist in the line layer or could not be indexed.NO_M_RANGE: failed to compute a valid M range for that route.NO_MATCH: failed to interpolate the point (includes discontinuity with snap disabled).
Note about
PK_INVALID:
- In Locate points from table,
PK_INVALIDcan appear as a critical per row (chainage (PK) not parseable).- In Locate points (manual), an invalid chainage (PK) input triggers a validation error and the algorithm stops (it is not reported as a per-event critical).
In segmented networks (multiple features per ROUTE_ID, or non-continuous M calibration), discontinuities may exist—areas not covered for certain chainage (PK) values, due to split geometries or M coverage gaps.
L-RAT distinguishes two situations:
Requested chainage (PK) is outside the route’s global available range (M_min–M_max, considering all geometries for the ROUTE_ID).
The algorithm clamps chainage (PK) to the nearest endpoint and marks:
ADJUSTED=1ADJUST_REASONincludesOUT_OF_RANGE
Requested chainage (PK) is within the global range, but no segment of that route covers it (not interpolable in any available LineStringM).
If Adjust to nearest available chainage (PK)… is enabled, the algorithm:
- finds the nearest covered chainage (PK),
- adjusts to it,
- marks
ADJUST_REASONwithGAP_SNAP.
If the option is disabled and requested chainage values (PK) falls in a discontinuity:
- the event is marked as a critical
NO_MATCHand no point is created.
A single event may accumulate both reasons. For example, an out-of-range chainage (PK) is clamped to an endpoint (
OUT_OF_RANGE) and if that endpoint is not covered by any segment,GAP_SNAPmay also apply.
Locates (interpolates) 1 or 2 points on a calibrated line layer from manually entered ROUTE_ID + Chainage/PK (and optionally an additional ID).
- Calibrated line layer (M) + ROUTE_ID field.
- M units.
- Point 1 (required):
ROUTE_ID (point 1)Chainage (PK) (point 1)Additional point ID (point 1)(optional)
- Point 2 (optional):
Define point 2(switch)ROUTE_ID (point 2)Chainage (PK) (point 2)Additional point ID (point 2)(optional)
Chainage (PK) format:
km+mmmor decimal km (e.g.,12+345,12.345,3,05).
- Located points (point layer)
ROUTE_ID(string)EVENT_ID(string) (only if any additional ID was provided)PK_REQ(string): requested chainage (PK)PK(string): located chainage (PK)ADJUSTED(int)ADJUST_REASON(string)STATUS(string) →OKon generated points
- Issues (table) (optional; only if there are rows)
ROUTE_IDEVENT_ID(only if present in output)PK_REQADJUSTED,ADJUST_REASONWARNINGS,CRITICALS
For
ADJUST_REASON,WARNINGS, andCRITICALS, see 5.1. Issues and traceability.
Locates points using an events table/layer: each row defines a point via ROUTE_ID + Chainage/PK (and optionally an additional ID).
- Calibrated line layer (M) +
ROUTE_IDfield. - Events table (each row = 1 point) with:
ROUTE_ID field in the tableChainage (PK) field in the table[km+mmm] or decimal (km)Additional Point ID field(optional) (PK_ID)
Chainage (PK) format:
km+mmmor decimal km (e.g.,12+345,12.345,3,05).
- Add table fields to output
If enabled, copies all table fields into the output.
If name collisions exist, suffix_TBLis added to copied fields.
- Located points (point layer)
ROUTE_ID(string)PK_ID(string) (only if “Event ID field” was configured)PK_REQ,PK,ADJUSTED,ADJUST_REASON,STATUS- (Optional) table fields (if enabled; with
_TBLif colliding)
- Issues (table) (optional; only if there are rows)
ROUTE_IDPK_ID(only if configured)PK_REQADJUSTED,ADJUST_REASONWARNINGS,CRITICALS
For
ADJUST_REASON,WARNINGS, andCRITICALS, see 5.1. Issues and traceability.
This subgroup extracts segments (lines) defined by ROUTE_ID + chainage (PK) (PK_START + PK_END) from an M-calibrated network/axis with valid M values (LineStringM / MultiLineStringM).
- Calibrated line layer (M) (
LineStringM / MultiLineStringM) and its ROUTE_ID field used to identify the road/route to extract. - M units:
Meters (m)/Kilometers (km). - Generate endpoint points (optional): creates 2 points per segment (start/end) with requested
PK_REQand finalPK.
Common advanced options:
- Tolerance (km) for M snap/rounding: helps resolve small mismatches within calibrated coverage (does not fix coverage discontinuities).
- Adjust to nearest available chainage point (PK): controls what happens when a PK falls into a discontinuity (incomplete geometry or M gaps):
- Enabled → the endpoint can be adjusted to the nearest covered chainage (PK) (
ADJUST_REASON=GAP_SNAP). - Disabled → the event becomes critical (
NO_MATCH) and no geometry is produced.
- Enabled → the endpoint can be adjusted to the nearest covered chainage (PK) (
- Generate issues table if any (adjustments/warnings/criticals): if enabled, records event/group issues when they exist (depending on algorithm).
Traceability in this subgroup relies on:
- Control fields in segment outputs.
- Optional endpoint points with per-endpoint fields.
- Optional Issues (table) (no geometry) with
WARNINGSandCRITICALS(and, depending on the algorithm, identifier fields).
PK_INI/PK_FIN(string): chainage (PK) values finally used to extract the segment (km+mmm).DIST_PK_KM(double): chainage (PK) distance in km betweenPK_INIandPK_FIN.DIST_GEOM_KM(double): geometric length of the extracted segment(s), in km.ADJUSTED(int):0/1. Indicates whether any adjustment was applied.ADJUST_REASON(string): reasons separated by;(e.g.,OUT_OF_RANGE;GAP_SNAP).N_PIECES(int): number of generated pieces. IfN_PIECES > 1, warningSEGMENT_SPLITis recorded.STATUS(string): status of the generated segment (OKfor created segments; critical events produce no geometry).
Creates 2 points per segment:
PK_REQ(string): requested chainage (PK) for that endpoint.PK(string): final chainage (PK) after adjustments.ADJUSTED(int),ADJUST_REASON(string).- Plus identifiers (depending on algorithm):
SEG_ID,PAIR_IDorEVENT_ID, andROUTE_ID.
- Created only if enabled and actual rows exist.
- For each event/group (depending on algorithm), records:
ADJUSTED/ADJUST_REASON(if adjustments occurred),WARNINGS(coded string list),CRITICALS(coded string list).
- If an event is critical: no output geometry exists, but a row is recorded in this table.
Adjustments (ADJUST_REASON)
OUT_OF_RANGE: An endpoint is outside the route’s global available range (M_min–M_max, considering all segments) and is clamped to the nearest endpoint.GAP_SNAP: Requested chainage (PK) is within the global range but falls into an M-coverage discontinuity (not interpolable in any available segment).
If adjustment is enabled, the nearest covered chainage (PK) is used.
Warnings (WARNINGS)
SEGMENT_SPLIT: Segment generated into multiple pieces (N_PIECES > 1).ODD_PK_IGNORED(only in Locate segments from points/events table*)*: In a(ROUTE_ID, PAIR_ID)group, an unpaired event is ignored.
Criticals (CRITICALS) — segment is not generated
NO_ROUTE: RequestedROUTE_IDdoes not exist (or is empty/null) in the indexed line layer.PK_INVALID: Some chainage (PK) is not parseable/convertible (e.g., non-parseablekm+mmmtext or decimal km).NO_M_RANGE: Failed to compute a valid M range for that route (considering all segments for thatROUTE_ID).NO_MATCH: Failed to extract geometry for the requested segment even if theROUTE_IDexists, typically due to:- endpoints in a discontinuity with
GAP_SNAPdisabled, - the requested portion not covered by any available
LineStringMfor thatROUTE_ID, - empty extraction after applying (or failing to apply) adjustments.
- endpoints in a discontinuity with
A single event may accumulate multiple reasons (e.g.,
OUT_OF_RANGE;GAP_SNAP) if, after clamping, the endpoint is not covered by any segment.
In segmented networks (multiple features per ROUTE_ID, or non-continuous M calibration), uncovered zones may exist for certain PK values. L-RAT distinguishes:
Requested chainage (PK) is outside the route’s global available range (M_min–M_max, considering all geometries for the ROUTE_ID).
The algorithm clamps to the nearest endpoint and marks:
ADJUSTED=1ADJUST_REASONincludesOUT_OF_RANGE
Requested chainage (PK) is within the global range, but no segment covers it (not interpolable in any available LineStringM).
If Adjust to nearest available chainage point (PK)… is enabled, the algorithm:
- finds the nearest covered chainage (PK),
- adjusts the endpoint to it,
- marks
ADJUST_REASONwithGAP_SNAP.
If the option is disabled and an endpoint falls in a discontinuity:
- the event is marked as a critical
NO_MATCHand no segment is generated.
Extracts 1 or 2 segments on a calibrated line layer from manually entered ROUTE_ID + chainage (PK) (PK_INI + PK_FIN)
- Calibrated line layer (M)
- Route identifier field
ROUTE_ID - M units
- Segment 1 (required):
Route identifier (segment 1)Start chainage (PK) (segment 1)End chainage (PK) (segment 1)OAdditional segment ID (SEG_ID) (segment 1)(optional)
- Segment 2 (optional):
Define second segmentRoute identifier (segment 2)Start chainage (PK) (segment 2)End chainage (PK) (segment 2)Additional segment ID (SEG_ID) (segment 2)(optional)
Chainage (PK) format:
km+mmmor decimal km (e.g.,12+345,12.345,3,05).
- Generate endpoint points (optional): creates 2 points per segment (start/end) with
PK_REQvs finalPK.
- Extracted segments (line layer)
Typical fields:
ROUTE_ID(string)SEG_ID(string) (only if any optional ID was provided)PK_INI,PK_FIN,DIST_PK_KM,DIST_GEOM_KM,ADJUSTED,ADJUST_REASON,N_PIECES,STATUS
-
Endpoint points (optional)
2 points per segment with:ROUTE_ID,PK_REQ,PK,ADJUSTED,ADJUST_REASON(+SEG_IDif present). -
Issues (table) (optional; only if there are rows)
IncludesWARNINGSandCRITICALS(see 6.1).
Generates segments from a table where each row provides one chainage value (PK), associated with ROUTE_ID and PAIR_ID. Segments are built by pairing chainage (PK) values within each identifier group (ideally unique per segment) for optimal algorithm behavior.
For each (ROUTE_ID, PAIR_ID):
- Sort chainage (PK) points numerically.
- Pair sequentially: (0–1), (2–3), (4–5)...
- If one chainage (PK) point is left unpaired, it is ignored and warning
ODD_PK_IGNOREDis recorded.
- Calibrated line layer (M) and its
ROUTE_IDfield. - Events (PK) table (each row = 1 chainage value (PK)):
ROUTE_ID field in the tablePAIR_ID field (segment/event) in the table- Chainage (PK) field in the table`
- M units
Chainage (PK) format:
km+mmmor decimal km (e.g.,12+345,12.345,3,05).
- Add table fields to output: copies table fields to the resulting segment. If a name collides with output fields, prefix
T_is added (e.g.,T_MY_FIELD). - Generate endpoint points (optional)
- Extracted segments (line layer)
Typical fields:
ROUTE_ID,PAIR_IDPK_INI,PK_FIN,DIST_PK_KM,DIST_GEOM_KMADJUSTED,ADJUST_REASON,N_PIECES,STATUS- (Optional) copied table fields (with
T_if colliding).
-
Endpoint points (optional)
2 points per segment with:ROUTE_ID,PAIR_ID,PK_REQ,PK,ADJUSTED,ADJUST_REASON. -
Issues (table) (optional; only if there are rows)
IncludesWARNINGS(e.g.,SEGMENT_SPLIT,ODD_PK_IGNORED) andCRITICALS(see 6.1).
Extracts segments from a segment table where each row defines one segment from ROUTE_ID + chainage (PK) (PK_INI + PK_FIN) and (optionally) an EVENT_ID.
- Calibrated line layer (M) and its
ROUTE_IDfield. - Segment table (each row = 1 segment) with:
ROUTE_ID field in the tableStart chainage (PK) fieldEnd chainage (PK) fieldAdditional segment ID field (EVENT_ID)(optional)
- M units
Chainage (PK) format:
km+mmmor decimal km (e.g.,12+345,12.345,3,05).
- Add table fields to output: copies table fields to the resulting segment.
If there is a name collision with output fields, prefixT_is added. - Generate endpoint points (optional)
- Extracted segments (line layer)
Typical fields:
ROUTE_IDEVENT_ID(only if configured)PK_INI,PK_FIN,DIST_PK_KM,DIST_GEOM_KMADJUSTED,ADJUST_REASON,N_PIECES,STATUS- (Optional) copied table fields (with
T_if colliding).
-
Endpoint points (optional)
2 points per segment with:ROUTE_ID,PK_REQ,PK,ADJUSTED,ADJUST_REASON(+EVENT_IDif present). -
Issues (table) (optional; only if there are rows)
IncludesWARNINGS(e.g.,SEGMENT_SPLIT) andCRITICALS(see 6.1).
Detects local curvature segments in a line layer, estimates their radius of curvature, and optionally computes curvature centers (circumcenters) and clusters them by proximity to produce a layer of grouped centers.
NOTE: the “curves” layer does not contain aggregated/continuous curve stretches; each feature is a local detection based on a consecutive triplet
p1–p2–p3(detections can overlap).
- Input line layer: vector line layer to analyze.
- Densification interval (Distance; CRS units)
Distance between inserted vertices when densifying the geometry. (Default: 15.0) - Minimum radius (Distance; CRS units): discards detections with too small radius (very tight curves or geometry noise). (Default: 2.0)
- Maximum radius (Distance; CRS units): filters detections with too large radius (very flat curves approaching straight lines). (Default: 50.0)
- Minimum distance between vertices (Distance; CRS units): avoids unstable calculations by ignoring triplets where
dist(p1,p2)ordist(p2,p3)is too small. (Default: 0.5) - Generate curvature-centers layer (bool): if enabled, computes curvature centers and generates the clustered centroid layer. (Default: False)
- Center clustering distance (Distance; CRS units): maximum distance to cluster centers into the same group. (Default: 10.0)
Applies only if “Generate curvature-centers layer” is enabled.
Validations (if they fail, the algorithm does not run):
- Densification interval > 0
- Minimum radius < Maximum radius
- Distances (min vertex distance / clustering) ≥ 0
- Curve segment layer (lines)
Each feature represents a local detection (tripletp1–p2–p3), with attributes:
ID_Curva(int): incremental identifier (0..n-1).ID_Centroide(int): associated cluster id, or-1if not applicable / centers not generated.Radio(double): estimated radius (in CRS units).Longitud(double): length of polylinep1–p2–p3(in CRS units).
- Centroids layer (clustered) (optional, points)
Generated only if “Generate curvature-centers layer” is enabled. Each feature represents a cluster of centers:
ID_Centroide(int): cluster identifier.Radio_medio(double): mean radius of curves assigned to the cluster.Conteo(int): number of curves in the cluster.
-
Densification
Each geometry is densified using the specified interval to obtain more regular vertices. -
Radius estimation from triplets
For each consecutive triplet(p1, p2, p3):
- Compute distances
a=dist(p1,p2),b=dist(p2,p3),c=dist(p3,p1). - Compute semiperimeter
s=(a+b+c)/2. - Compute area with Heron’s formula:
area = sqrt(s(s−a)(s−b)(s−c)). - Estimate circumcircle radius:
R = (a·b·c)/(4·area). - If points are nearly colinear (area ~ 0), skip the triplet.
- Accept detection only if
Minimum radius < R < Maximum radius(strict filters).
- Curvature centers and clustering (optional)
- Compute the circumcenter for each valid triplet.
- Cluster centers by proximity using “Center clustering distance”.
- Update cluster centroid as the mean of assigned centers.
-
Use a projected CRS in meters (UTM or similar).
The algorithm uses planar CRS distances; in geographic CRS (lat/long) values will be wrong. -
Densification interval is the most sensitive parameter.
- too large → you may miss curves (too few vertices)
- too small → higher cost and may generate too many detections (and “noise”)
-
If the geometry has noise or too many vertices, false detections may occur.
-
If the centroid layer is empty:
- review
Minimum/maximum radius,Minimum distance between vertices, andCenter clustering distance
- review
-
To reduce noise / excessive detections:
- slightly increase Densification interval (less sensitivity),
- increase Minimum radius (discard very tight/noisy curves),
- decrease Maximum radius (discard near-straight segments),
- increase Minimum distance between vertices (avoid degenerate triplets).
-
To avoid missing curves:
- reduce Densification interval (more detail),
- ensure
Minimum radiusis not too high, - ensure
Maximum radiusis not too low.
This subgroup includes two algorithms to compute longitudinal profiles and slopes (%) from a DEM (local raster or WCS) and then automatically plot results.
Traceability in this subgroup relies on:
- Quality fields in outputs (
SLOPE_TYPEin both the table and the segmented layer). - Warnings in the Processing log (e.g., missing optional fields) and errors when results cannot be produced (e.g., no valid data to plot).
In both the table and the segmented layer, SLOPE_TYPE indicates the origin/quality of the slope value:
REAL: slope computed with valid elevation data at both segment ends.INTERP: slope filled by interpolation between neighboring segments with real slope.EXTRAP: slope filled by extrapolation (keeps nearest valid value).NODATA: insufficient information (slope not available).
Note: the algorithm fills missing slopes to keep a continuous segmented layer, while preserving traceability with
SLOPE_TYPE.
Generates PNG plots and an HTML report (index) from a table/dataset containing:
- distance from origin (meters),
- elevation (profile),
- and optionally slope (%).
It is designed to plot the table generated by Slope and Longitudinal Profile, but it can be used with any compatible table.
- Input table/layer (can be non-spatial).
- ID field (one plot per ID) (optional; default
ID_Segmento): if present, generates a set of plots per ID. If the field does not exist, a warning is logged and everything is treated as one group (ALL). - X field (distance from origin, meters) (default
Dist_Origen_metros) - Y field (elevation/profile) (default
Cota_SUAV) - Slope field (%) (optional; default
SLOPE): if missing, a warning is logged and slope is treated asNaN. - Use chainage (PK) (if exists) (bool): switches X-axis labeling to chainage (PK) values (
K+MMM) using the chainage (PK) field. If enabled but the field does not exist, a warning is logged and Chainage (PK) mode is disabled. - Chainage (PK) field (km, e.g., 91.740) (optional; default
m_field_PK_KM) - Show axis labels (bool): Enabled: displays axis titles and labels. Disabled: no titles/labels are shown, which makes the plot easier to reuse in other languages.
- The profile is always plotted against real distance (
X_FIELD, meters). - If Use chainage (PK) is enabled, chainage (PK) is used only to build the tick labels on the X axis.
- The elevation axis does not necessarily start at 0; it automatically adjusts its limits to the displayed range.
Check Processing Toolbox → Results Viewer
- Folder with PNGs per ID:
perfil_<ID>.pngperfil_pendiente_<ID>.png
- HTML report (index) with previews and links.
From a line (axis) and a DEM, generates:
- a longitudinal profile table (cumulative distance vs elevation) + slopes (%),
- and a segmented layer (micro-segments) for easier cartographic representation.
- Input line layer (axis/axes to analyze).
- DEM (local raster or WCS).
- Segment ID field (optional): if provided, preserved as
ID_Segmentoin outputs. - Sampling step (m). 0 = raster resolution (default 0): if
=0, the algorithm computes an automatic step from the DEM pixel size (converted to meters). - Reverse profile direction: swaps origin (start ↔ end).
-
DEM sampling method:
Nearest: uses the nearest pixel value. Fast, preserves original values but can look stepped.Bilinear: interpolates from 4 neighboring pixels, producing smooth/stable results.Cubic(defaultCubicwith fallback to bilinear if it fails): larger neighborhood interpolation (smoother, slower).
-
Profile smoothing (default
Savitzky–Golay):NoneMoving average: replaces each value with the window mean. Smooths noise but can be affected by outliers (peaks/artifacts). With the same window size, usually smooths more than Savitzky–Golay and can “flatten” changes.Moving median: replaces each value with the window median. Robust to outliers; often a good option when the DEM has local artifacts (trees, bridges...).Savitzky–Golay(requires numpy; falls back to moving average if unavailable): smooths while better preserving shape than moving average, but can introduce noise if the window is small and polynomial order high.
-
Smoothing window: number of samples in the filter window. Small windows smooth little; large windows smooth more but may flatten real changes. Typically 7–15.
-
Polynomial order (Savitzky–Golay): higher values preserve complex shapes better but can amplify noise if the window is small.
-
Use M (if present) to add chainage (PK) values to the table (default False)
Addsm_field_PK_KMandm_field_PK_MMMto the table if the geometry has valid M. -
M units:
meters/kilometers(to interpret M and convert to km).
- Profile table (non-spatial) — 1 row per sample
Fields:
ID_Segmento(string)Dist_Origen_metros(double)Cota_RAW_metros(double)Cota_SUAV(double)SLOPE(double)SLOPE_TYPE(string:REAL/INTERP/EXTRAP/NODATA)
(Optional, if “Use M” and M is valid on the line):
m_field_PK_KM(double) — chainage (PK) in km (float)m_field_PK_MMM(string) — chainage (PK) formattedkm+mmm
- Segmented profile (lines) — 1 micro-segment between consecutive samples
Fields:
ID_Segmento- Distances:
D_Ini_metros,D_Fin_metros,D_Mid_metros - RAW elevations:
Z_Ini_RAW_metros,Z_Fin_RAW_metros,Z_Mid_RAW_metros - Smoothed elevations:
Z_Ini_SUAV_metros,Z_Fin_SUAV_metros,Z_Mid_SUAV_metros SLOPE,SLOPE_TYPELong_tramo(double)
- DEM sampling: samples elevation along the line for a list of distances (always includes the end).
- Smoothing: applied to the elevation series (
Cota_RAW_metros → Cota_SUAV). - Slope (%): computed as
100 * dz / dxbetween consecutive samples.- If consecutive elevations are missing, the initial slope is
Noneand can later be filled (interp/extrap) to keep continuity, recorded inSLOPE_TYPE.
- If consecutive elevations are missing, the initial slope is
- Chainage (PK) values from M (optional):
- Interpolates M along vertices.
- If M is not usable (e.g., some vertex has M/NaN), chainage (PK) fields are
NULL.
- For coherent slopes, use a projected CRS (meters) and a DEM with suitable resolution for the expected detail.
- If the DEM is noisy:
- try
Moving medianorSavitzky–Golay, - increase the sampling step,
- and review
SLOPE_TYPEto distinguish real slopes from filled values.
- try
This project is distributed under the GNU General Public License v3.0 (GPL-3.0).
You may use it, modify it, and share it freely under the terms of this license.
- LinkedIn: https://www.linkedin.com/in/javierhpiris
- GitHub: https://github.com/Javisionario





