Ticket #1058 (new enhancement)
[raster] Two-raster spatial operations framework proposal
|Reported by:||bnordgren||Owned by:||pracine|
I doubt this is usable yet, but there's enough here to start people talking (e.g., draw fire). This is a C based framework for two-raster operations returning a raster result. The two "major phases" of such a task are: precalculate the expected extent of the result; and iterate over the result raster to produce one value per cell. Both major phases have been encapsulated in their own function, and both use function callbacks as a mechanism to implement extension points. The framework takes differing alignments, cell sizes, and projections into account, such that the callbacks need only to worry about their fundamental task.
The grid extent function has one extension point defined: calculate extent of result. The remainder of the function retrieves the extents of the two input rasters and projects them into the result srid, creates a raster of the appropriate size, and sets various metadata fields. The four current implementations of this extension point calculate extents for "intersection", "difference", "union" and "symdifference".
The result-raster-iteration function has two extension points defined: determine whether a cell is included in the result; and provide a value for the cell.
There are four implementations of "determine whether a cell is included in the result", corresponding to the four extent calculations: "intersection", "difference", "union" and "symdifference".
There are two implementations of "provide a value for the cell": one generates a mask; the other copies image data from one of the input rasters (r1 if possible, r2 if not). The implementation which copies image data sets "not present" cells to nodata.
Provided one can access Postgresql's expression parser from C, it should be possible to implement a 2 raster MapAlgebra by implementing a "provide a value for the cell" extension. The interface may have to be augmented slightly to allow "user" parameters to be passed (such as the expression itself, as well as the bindings from symbol to band)