43 | | '''ST_MapAlgebra(raster|geometry, [raster|geometry,…], ‘mathematical expression’, ‘raster’ |’geometry’) -> raster/geometry'''[[BR]] |
| 48 | |
| 49 | '''ST_MapAlgebra(raster|geometry, [raster|geometry,…] ‘mathematical expression’, ‘raster’ |’geometry’) -> raster/geometry''' |
| 50 | |
| 51 | Variant 1: ST_MapAlgebra(raster|geometry, [raster|geometry,…] ‘mathematical expression’, ‘raster’ |’geometry’, originx, originy, pixelsizex, pixelsizey, rotation ) -> raster/geometry |
| 52 | |
| 53 | Variant 2: ST_MapAlgebra(raster|geometry, [raster|geometry,…] 'mathematical expression', 'raster' |'geometry', integer) ->raster/geometry |
| 54 | |
| 55 | Variant 3: ST_MapAlgebra(raster|geometry, [raster|geometry,…] 'mathematical expression', 'raster' |'geometry', raster) ->raster/geometry |
| 56 | |
| 57 | The first raster passed to ST_MapAlgebra is the 'master' raster, unless either: |
| 58 | 1 additional parameter specifies the index (in the parameter list) of the 'master' raster.[[BR]] |
| 59 | 1 additional parameter specifies a raster whose origin and cell size should be used to compute the output raster.[[BR]] |
| 60 | 4 additional parameters are passed specifying the origin, cell size, and raster rotation. |
| 61 | |
| 62 | This function implicitly calls ST_Intersects(raster|geometry, [raster|geometry,…]) to detect if the rasters are overlapping before performing any computation. Additionally, the resulting raster will have the same extent as the result of ST_Intersection(raster, integer, geometry). |
| 63 | |
| 64 | One of the implications of the ST_Intersects inclusion is that: |
| 65 | SELECT ST_MapAlgebra(rast1, rast2, mathExpr) FROM mytable WHERE ST_Intersects(rast1, rast2) |
| 66 | will be faster than: |
| 67 | SELECT ST_MapAlgebra(rast1, rast2, mathExpr) FROM mytable |
| 68 | |
| 69 | '''Open Question:''' Should ST_MapAlgebra resample rasters internally, or produce a raster that can be processed by ST_Resample? If so, variant 1 and variant 3 can be removed, and all ST_MapAlgebra results can be processed through ST_Resample, like: |
| 70 | ST_Resample(ST_MapAlgebra(raster, [raster,…] 'mathematical expression', integer), originx, originy, pixelsizex, pixelsizey)[[BR]] |
| 71 | ST_Resample(ST_MapAlgebra(raster, [raster,…] 'mathematical expression', integer), rastergrid) |
| 72 | |