LineSmootherJaitools¶
Smooths lines with cubic Bezier curves through all their vertices: the lines keep their vertices and get round turns between them. It suits lines with few vertices, as the simplified ones, drawn with corners.
Details¶
The smoothed line passes through all the vertices of the original one: each segment is replaced by a cubic Bezier curve of 10 vertices, with the control points set by the neighbouring segments, so the line gets 9 new vertices for each segment. With an alpha of 1 the curves are the straight segments, so the line keeps its shape, only with more vertices; with 0 they are the roundest. Since the curve doesn’t cut the corners, on the staircase lines of a vectorized raster it rounds the steps instead of removing them: simplify the lines first, with VectorSimplifier, to smooth their general shape.
Only the lines of the features are smoothed, as multi lines: features without lines are left out.
Parameters¶
Smooths lines with cubic Bezier curves through their vertices, with the line smoother of the jaitools project.
Toolbox folder: Vector Processing
Status: Certified
Keywords: Smoothing, Vector, Bezier
Authors: Andrea Antonello
Class: org.hortonmachine.modules.LineSmootherJaitools
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
vector file |
The vector containing the lines to be smoothed. |
||
|
double |
|
A value between 0 and 1 (inclusive) specifying the tightness of fit of the smoothed line: 0 is the loosest, 1 keeps the straight segments. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The smoothed features. |
References
Shemanarev, M. Interpolation with Bezier Curves: a very simple method of smoothing polygons. http://www.antigrain.com/research/bezier_interpolation/index.html
Example¶
The example smooths the contour lines simplified by VectorSimplifier, with a tolerance of 25 m:
import org.hortonmachine.modules.LineSmootherJaitools
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
var smoother = new LineSmootherJaitools()
// the contour lines simplified by VectorSimplifier: on the original ones,
// the curves would round the steps of the cells
smoother.inVector = folder + "contours_simple.shp"
// the roundest curves
smoother.pAlpha = 0.0
smoother.outVector = folder + "contours_bezier.shp"
smoother.process()
A detail of the smoothed lines in red, over the original contours of ContourExtractor in blue: the curves through the few vertices of the simplified lines follow the general course of the contours, without their small turns:
The LineSmootherMcMaster smooths instead by averaging the vertices.