RasterCorrector

Sets single cells of a raster to new values, or to novalue. It is meant for a few manual fixes, as a spike of an elevation model, a pit that a pit filling should not fill, or the outlet cell that a network extraction needs to be a channel. The cells are given by their column and row, as shown by the tools that inspect a raster, or by the coordinates of a point read off a map.

To change many cells, use Mapcalc or RasterNull.

Details

The corrections are a comma separated list of triplets, as col1,row1,value1,col2,row2,value2: the column and row start from 0 at the north-west corner, the row 0 being the northern one. With the coordinates switch the triplets are east,north,value instead, in the reference system of the raster, as read off a map: each one corrects the cell that contains the point. The cells outside of the raster are left out with a warning. A value equal to the novalue of the raster removes the cell. The byte, short and integer rasters keep their type, the others become double.

It is meant for a few manual fixes, as a spike in an elevation model or the outlet cell that a network extraction needs to be a channel: to change many cells, Mapcalc or RasterNull are the tools.

Parameters

Sets single cells of a raster to new values, given by their column and row or by their coordinates.

Toolbox folder: Raster Processing
Status: Certified
Keywords: Raster, Correct, Edit, Cells
Authors: Andrea Antonello
Class: org.hortonmachine.modules.RasterCorrector

Inputs

Parameter

Type

Unit

Default

Description

inRaster

raster file

The raster to correct.

pCorrections

String

The corrections, as a comma separated list of triplets: col1,row1,value1,col2,row2,value2… or, with the coordinates, east1,north1,value1…

doCoordinates

boolean

false

If true, the triplets have the coordinates of the cells instead of their column and row.

Outputs

Parameter

Type

Unit

Description

outRaster

output file

The corrected raster.

Example

The example runs on the sample elevation model of the manual, dtm_flanginec.tif in docs/manual/modules/maps/data:

import org.hortonmachine.modules.RasterCorrector

// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"

// two cells set by column and row, the first one north-west, then removed with the novalue
var corrector = new RasterCorrector()
corrector.inRaster = folder + "dtm_flanginec.tif"
corrector.pCorrections = "120,80,1450.0, 121,80,-9999"
corrector.outRaster = folder + "dtm_corrected.tif"
corrector.process()

// the same with the coordinates of a point read off the map, in the reference system of the raster
corrector = new RasterCorrector()
corrector.inRaster = folder + "dtm_flanginec.tif"
corrector.pCorrections = "1638345.0,5113635.0,1450.0"
corrector.doCoordinates = true
corrector.outRaster = folder + "dtm_corrected_xy.tif"
corrector.process()