RasterCompare

Compares two rasters: their coordinate reference systems and grids, and, on the same grid, their values cell by cell. It checks that a computation repeated with other settings or another version of a module gives the same result, and where and by how much two rasters differ.

Details

The report lists the differences of the coordinate reference systems, of the bounds, of the resolutions and of the columns and rows. If the two grids are the same, the values are compared cell by cell: it counts the cells with equal values, with different values, and the cells that are novalue in only one of the rasters, which count as different. Of the values that differ it gives the max and the mean absolute difference, and the first different cells, with their column, row and values.

The tolerance sets when two values are equal: with 0 they need to be exactly the same, with 0.01 the differences up to one centimeter of two elevation models are not counted. The outputs carry the result to a script, as a test that a computation still gives the reference raster.

Parameters

Compares two rasters, their grids and their values cell by cell.

Toolbox folder: Raster Processing
Status: Certified
Keywords: Compare, Difference, Raster
Authors: Andrea Antonello
Class: org.hortonmachine.modules.RasterCompare

Inputs

Parameter

Type

Unit

Default

Description

inRaster1

raster file

The first raster.

inRaster2

raster file

The second raster.

pTolerance

double

0

The largest difference of two values seen as equal (default 0).

pMaxReported

int

10

The number of different cells listed in the report (default 10).

Outputs

Parameter

Type

Unit

Description

outSameGrid

Boolean

True if the rasters have the same grid, and so their values were compared.

outDifferent

Long

The number of cells with different values, novalue in one raster only included.

outMaxDifference

Double

The max absolute difference of the cells valid in both rasters.

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.RasterCompare

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

// the elevation model against its rounding to the decimeter by RasterValueRounder
var compare = new RasterCompare()
compare.inRaster1 = folder + "dtm_flanginec.tif"
compare.inRaster2 = folder + "dtm_rounded.tif"
compare.pMaxReported = 3
compare.process()

println "different cells: " + compare.outDifferent + ", max difference: " + compare.outMaxDifference

The report of the sample elevation model and its rounding to the decimeter by RasterValueRounder:

GRID GEOMETRY
================================
The rasters have the same bounds and resolution.

VALUES
================================
Equal cells: 261
Different cells: 123501
Cells with novalue in only one raster: 0
Cells with novalue in both rasters: 4393
Max absolute difference: 0.0500000000001819
Mean absolute difference: 0.025062832886505352
First different cells (raster 1 - raster 2):
	col 7, row 0: 1207.594970703125 - 1207.6
	col 8, row 0: 1217.385986328125 - 1217.4
	col 9, row 0: 1223.239990234375 - 1223.2

The rounding moves the values by 2.5 cm on average and by 5 cm at most, as it should.