[postgis-devel] [PostGIS] #860: [raster] Modify ST_MapAlgebra to handle expressions and user-functions

PostGIS trac at osgeo.org
Wed Mar 16 13:47:01 PDT 2011


#860: [raster] Modify ST_MapAlgebra to handle expressions and user-functions
----------------------------+-----------------------------------------------
 Reporter:  dzwarg          |       Owner:  dzwarg       
     Type:  enhancement     |      Status:  new          
 Priority:  medium          |   Milestone:  PostGIS 2.0.0
Component:  postgis raster  |     Version:  trunk        
 Keywords:                  |  
----------------------------+-----------------------------------------------
 1. Modify ST_MapAlgebra to ST_MapAlgebraExp (with expression) to evaluate
 cells of a raster with a single expression.
  1. Create ST_MapAlgebraFct (with function) to evaluate cells of a raster
 with a user-specified plpgsql function.

 To support item 2, the rt_pg layer needs a hook from SQL to callback a
 specified function. I am calling this '''ST_CallUserFn'''. This method
 takes a callback plpgsql function that will be evaluated for every cell in
 the raster.

 A callback plpgsql function currently must be defined in the following
 manner:

 {{{
 #!sql
 CREATE OR REPLACE FUNCTION MyUserFunctionName(cell FLOAT, VARIADIC args
 TEXT[])
   RETURNS FLOAT
 AS $$
 DECLARE
   -- Some custom arguments, always passed in as TEXT type.
   arg1 FLOAT;
   arg2 FLOAT;
 BEGIN
   -- To use your custom arguments, cast them to the type you need,
   -- and perform your calculations. Return the new value for the
   -- new raster cell's value.
   RETURN cell;
 END;
 $$ LANGUAGE plpgsql;
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/860>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list