VectorSimplifier¶
Simplifies the geometries of a vector, dropping the vertices that do not change their shape beyond a tolerance, or rounds their coordinates to a given precision. The lines extracted from rasters, as the contours of ContourExtractor or the polygons of Vectorizer, have a vertex for each cell crossed: simplified, they are lighter to store and draw, and lose the staircase of the cells.
Details¶
TopologyPreservingSimplifier keeps the result valid, with the same dimension and number of parts, also with large tolerances; Douglas Peucker is faster but can produce invalid or collapsed geometries. Both drop the vertices that are closer than the tolerance, in map units, to the simplified line. The precision reduction instead rounds the coordinates to a grid of 1/scale: with a scale of 1000, to the third decimal.
Each part of a multi geometry is simplified on its own, so the topology between the parts is not preserved, and the parts are returned as a geometry collection.
Parameters¶
Collection of vector simplification algorithms.
Toolbox folder: Vector Processing
Status: Certified
Keywords: Simplify, OmsLineSmootherMcMaster, OmsLineSmootherJaitools
Authors: Andrea Antonello
Class: org.hortonmachine.modules.VectorSimplifier
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
vector file |
The vector to be simplified. |
||
|
String |
|
The simplification method. Allowed values: |
|
|
double |
|
The distance tolerance for the simplification. |
|
|
Double |
|
The amount by which to multiply a coordinate after subtracting the offset, to obtain a precise coordinate |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The simplified vector. |
Example¶
The example runs on the contour lines of ContourExtractor, extracted from the sample elevation model of the manual:
import org.hortonmachine.modules.VectorSimplifier
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
var simplifier = new VectorSimplifier()
// the contour lines of ContourExtractor
simplifier.inVector = folder + "contours.shp"
// drop the vertices closer than 25 m to the simplified lines
simplifier.pTolerance = 25.0
simplifier.outVector = folder + "contours_simple.shp"
simplifier.process()
The contour lines of ContourExtractor, simplified with a tolerance of 25 m.¶