RasterNull¶
Sets the cells of one value of a raster to no-data, or, with the inverse, all the cells of the other values. It cleans the rasters whose missing data are stored as a value, and extracts the cells of one class of a classified raster, as a mask for other modules.
Details¶
The typical use is a value that means no data but isn’t declared as novalue, as the 0 of the frame of an orthophoto or the -32768 of some elevation models. The inverse switch keeps only the cells of the value and sets all the others to novalue, which gives the mask of a class from a raster of classes.
The value is compared at float precision, so 1.1 finds also the cells of a float raster, that stores it as 1.100000023841858: the values nearer than about one ten millionth of the value are taken as equal. To null a range of values RangeLookup or Mapcalc are the tools. The cells that are novalue in the input stay novalue. A null value given sets the nulled cells to that value instead of the novalue, for example 0 to make a 1/0 raster with the inverse.
Parameters¶
Sets the cells of a given value of a raster to novalue, or all the other cells.
Toolbox folder: Raster Processing
Status: Certified
Keywords: Null, Novalue, Mask, Raster
Authors: Andrea Antonello
Class: org.hortonmachine.modules.RasterNull
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
raster file |
The raster to modify. |
||
|
Double |
The value to set to null. |
||
|
Double |
An optional value to give to the nulled cells instead of the novalue. |
||
|
boolean |
|
If true, keeps the cells of the value and sets all the others to null. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The new raster. |
Example¶
The example runs on the sample elevation model of the manual, dtm_flanginec.tif in docs/manual/modules/maps/data, each module on the outputs of the previous ones:
import org.hortonmachine.modules.RasterNull
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// only the middle elevation belt of RangeLookup, from 1300 to 1700 m
var rasterNull = new RasterNull()
rasterNull.inRaster = folder + "elevation_belts.tif"
rasterNull.pValue = 2.0
rasterNull.doInverse = true
rasterNull.outRaster = folder + "belt_middle.tif"
rasterNull.process()
The cells of the middle elevation belt of RangeLookup, from 1300 to 1700 m: all the other cells are no-data.¶