| 1565 | This set of 2-raster ST_MapAlgebra functions require a user-provided function instead of expressions. The user-provided function must receive three parameters (two double precision and one VARIADIC text array) and returns one double precision value. A template for this user-provided function would be: |
| 1566 | |
| 1567 | {{{ |
| 1568 | CREATE OR REPLACE FUNCTION userfunction(rast1 double precision, rast2 double precision, VARIADIC arg text[]) |
| 1569 | RETURNS double precision |
| 1570 | AS $$ |
| 1571 | DECLARE |
| 1572 | BEGIN |
| 1573 | -- your code here |
| 1574 | END; |
| 1575 | $$ |
| 1576 | LANGUAGE 'plpgsql'; |
| 1577 | }}} |
| 1578 | |
| 1579 | The function should be able to support a NULL input parameter. The function may also be STRICT. |
| 1580 | |
| 1581 | 1. ST_MapAlgebraFct( |
| 1582 | rast1 raster, band1 integer,[[BR]] |
| 1583 | rast2 raster, band2 integer,[[BR]] |
| 1584 | userfunction regprocedure,[[BR]] |
| 1585 | pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',[[BR]] |
| 1586 | VARIADIC userargs text[] DEFAULT NULL |
| 1587 | ) |
| 1588 | |
| 1589 | {{{ |
| 1590 | ST_MapAlgebraFct(r1.rast, 1, r2.rast, 1, 'raster_mapalgebra_intersection(double precision, double precision, text[])'::regprocedure, '32BF', 'INTERSECTION') |
| 1591 | }}} |
| 1592 | |
| 1593 | 2. ST_MapAlgebraFct( |
| 1594 | rast1 raster,[[BR]] |
| 1595 | rast2 raster,[[BR]] |
| 1596 | userfunction regprocedure,[[BR]] |
| 1597 | pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',[[BR]] |
| 1598 | VARIADIC userargs text[] DEFAULT NULL |
| 1599 | ) |
| 1600 | |
| 1601 | {{{ |
| 1602 | ST_MapAlgebraFct(r1.rast, r2.rast, 'raster_mapalgebra_intersection(double precision, double precision, text[])'::regprocedure, '32BF', 'INTERSECTION') |
| 1603 | }}} |
| 1604 | |
| 1605 | 3. ST_MapAlgebraFct( |
| 1606 | rast1 raster,[[BR]] |
| 1607 | rast2 raster,[[BR]] |
| 1608 | userfunction regprocedure,[[BR]] |
| 1609 | VARIADIC userargs text[] |
| 1610 | ) |
| 1611 | |
| 1612 | {{{ |
| 1613 | ST_MapAlgebraFct(r1.rast, r2.rast, 'raster_mapalgebra_intersection(double precision, double precision, text[])'::regprocedure, '32BF', 'INTERSECTION') |
| 1614 | }}} |