[postgis-tickets] [PostGIS] #2603: [raster] Add docs for ST_MapAlgebra with mask parameter

PostGIS trac at osgeo.org
Mon Oct 5 10:35:24 PDT 2015


#2603: [raster] Add docs for ST_MapAlgebra with mask parameter
------------------------+---------------------------
  Reporter:  dustymugs  |      Owner:  dustymugs
      Type:  task       |     Status:  new
  Priority:  critical   |  Milestone:  PostGIS 2.2.0
 Component:  raster     |    Version:  trunk
Resolution:             |   Keywords:
------------------------+---------------------------

Comment (by dustymugs):

 Probably not the best example...

 The idea is that instead of distancex and distancey, the mask (an odd
 numbered array in X and Y) can provide a means to selectively filter
 pixels.

 In the example below, I provide a mask of

 {{{
 1 0 0
 0 1 0
 0 0 1
 }}}

 which drives the neighborhood fetch to only pass those pixels in the
 neighborhood where the mask element is 1 (true) to the MapAlgebra Callback
 function.

 {{{
 DROP FUNCTION sample_callbackfunc(double precision[],integer[],text[]);
 CREATE OR REPLACE FUNCTION sample_callbackfunc(v double precision[][][],
 pos int[][], VARIADIC userargs text[])
 RETURNS double precision
 AS $$
 BEGIN
         RAISE NOTICE 'v = %', v;
         RAISE NOTICE 'pos = %', pos;
         RAISE NOTICE 'userargs = %', userargs;
         RETURN v[1][1][1];
 END;
 $$ LANGUAGE 'plpgsql';

 WITH foo AS (
         SELECT 1 AS rid, ST_AddBand(ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1,
 0, 0, 0), 1, '16BUI', 1, 0) AS rast
 )
 SELECT
         ST_DumpValues(
                 ST_MapAlgebra(
                         rast, 1,
                         'sample_callbackfunc(double precision[], int[],
 text[])'::regprocedure,
                         ARRAY[[1, 0, 0],[0, 1, 0],[0, 0, 1]]::double
 precision[], False
                 )
         )
 FROM foo
 }}}

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/2603#comment:9>
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-tickets mailing list