Note
This standalone script is no longer actively developed. Its functionality is now maintained as part of L-RAT, a broader QGIS plugin for linear referencing and analysis.
This QGIS Processing script extracts curve segments from a densified line layer, calculates their radius of curvature, optionally groups nearby curve centers, and produces up to two output layers:
-
Curves layer
Each feature represents a curve segment with attributes:ID_Curva: unique ID for the curve segmentID_Centroide: ID of the cluster centroid the curve belongs to (or-1if not applicable)Radio: curvature radius (m)Longitud: segment length (m)
-
Centroids layer (optional)
Each feature represents a cluster of nearby curve centers, with attributes:ID_Centroide: unique cluster IDRadio_medio: mean radius of all curves in the cluster (m)Conteo: number of curves in the cluster
- Input line layer: Vector line layer to be analyzed.
- Densification interval (m): Distance between added vertices when densifying lines (default:
15.0). - Minimum radius (m): Exclude curves tighter than this threshold (default:
2.0). - Maximum radius (m): Exclude curves flatter than this threshold (default:
50.0). - Minimum distance between vertices (m): Skip triplets where vertices are too close (default:
0.5). - Generate centroid layer (boolean): If enabled, produces a second point layer with curve centers (default:
False). - Cluster distance (m): Maximum distance for grouping curve centers into the same cluster (default:
10.0).
The script analyzes every triplet of consecutive vertices (p1, p2, p3) in the densified line layer:
-
Compute edge lengths:
a = dist(p1, p2)b = dist(p2, p3)c = dist(p3, p1)
-
Compute semi-perimeter:
s = (a + b + c) / 2
-
Compute area using Heron’s formula:
area = sqrt(s(s−a)(s−b)(s−c))
-
Compute circumcircle radius:
R = (a·b·c) / (4·area)
⚠️ If points are nearly collinear (area ≈ 0), no radius is calculated.
If enabled, curve centers are also computed and then clustered based on proximity.
- Download the script file
Radios_curva.py. - In QGIS:
- Open Processing Toolbox → Scripts → Add Script to Toolbox.
- Load the script into your QGIS environment.
📸 Example of the installation step:

- The algorithm will appear at your Processing Toolbox under the group: Script → Analisis de linea → Extraer curvas y centroides.
- Road safety studies: detecting tight bends.
- Geometric road design checks.
- Mapping and categorizing curvature for line-based infrastructures.
Q: Why are some curves missing in the output?
- They might not fall within the specified min/max radius range.
- Triplets of points too close together may be skipped due to the minimum distance filter.
- Collinear points do not produce a valid radius.
Q: Why do I get an empty centroid layer?
- Ensure the "Generate centroid layer" option is enabled.
- Curves must have valid centers to form clusters.
Q: What CRS should I use?
- Use a projected coordinate system (e.g., UTM) where distances are measured in meters. Using geographic CRS (lat/long) will give incorrect results.
Q: Can I adjust how many vertices are generated?
- Yes, by changing the densification interval. Smaller values create more vertices and higher precision, but increase computation time.
- The algorithm assumes reasonably clean line geometries; noisy data may produce many false curves.
- Results depend heavily on the chosen densification interval. Too coarse → missed curves; too fine → excessive computation.
- The clustering method is purely distance-based; it does not account for curve orientation or road context.
- Nearly collinear triplets of points cannot generate valid radii (they are skipped).
- Designed for projected CRS in meters — using geographic CRS (lat/long) could give meaningless distances.
This project is released under the GNU General Public License v3.0. Feel free to use, modify, and share.
Javi H. Piris
- Email: [email protected]
- GitHub: @Javisionario

