VectorFieldRounder¶
Rounds the values of a numeric field of a vector, as the statistics computed by other modules with more decimals than they mean, to make the tables lighter and easier to read.
Details¶
The pattern is a Java DecimalFormat pattern, with the dot as decimal separator whatever the language of the system: 0.00 rounds to two decimals, # to the integer. The values are rounded half up, so 2.5 becomes 3 and 2.25 with 0.0 becomes 2.3. The values that are not numbers, as the empty ones, are left as they are.
The field keeps its type, and a shapefile stores the values with the number of decimals that the field has in its table.
Parameters¶
Rounds the values of a numeric field of a vector to the decimals of a pattern.
Toolbox folder: Vector Processing
Status: Certified
Keywords: Round, Vector, Attributes
Authors: Andrea Antonello
Class: org.hortonmachine.modules.VectorFieldRounder
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
vector file |
The vector of which to round a numeric value. |
||
|
String |
The numeric field to round. |
||
|
String |
The rounding pattern, as 0.00 for two decimals. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The modified vector. |
Example¶
The example rounds to the meter the mean elevation that RasterCatToFeatureAttribute computed for the cells of the grid:
import org.hortonmachine.modules.VectorFieldRounder
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
var rounder = new VectorFieldRounder()
// the cells with the elevation of RasterCatToFeatureAttribute
rounder.inVector = folder + "grid_elev.shp"
// the mean elevation to the meter
rounder.fRound = "elev_avg"
rounder.pPattern = "0"
rounder.outVector = folder + "grid_elev_round.shp"
rounder.process()
The first cells, before and after:
id |
elev_avg before |
elev_avg after |
|---|---|---|
0 |
1078.607 |
1079 |
1 |
1303.779 |
1304 |
2 |
1520.539 |
1521 |
3 |
1742.999 |
1743 |