[postgis-devel] [PostGIS] #1245: [raster] ST_AddBand that can take multiple bands to an existing raster (was: [raster] ST_AddMultiBand that can add multiple bands to an existing raster)

PostGIS trac at osgeo.org
Sat Nov 12 04:55:24 PST 2011


#1245: [raster] ST_AddBand that can take multiple bands to an existing raster
----------------------------+-----------------------------------------------
 Reporter:  robe            |       Owner:  pracine              
     Type:  enhancement     |      Status:  new                  
 Priority:  medium          |   Milestone:  PostGIS Raster Future
Component:  postgis raster  |     Version:  trunk                
 Keywords:                  |  
----------------------------+-----------------------------------------------

Comment(by robe):

 Trying to come up with examples for the docs has forced me to think about
 this a bit more.  Not only would it save many people from getting carpal
 tunnel syndrome, but like I said I think it would improve speed as fewer
 raster memory copy operations required and it will also improve
 readability.  So a win, win, win in my book.  here is my usecase that I am
 frustrated I can't use.  I also changed this to ST_AddBand since I think
 we can fold it in -- the signature would be

 ST_AddBand(raster[])

 Now getting to my use case.  Lets say I have a single band 32BF raster
 (for sake of argument lets call it solar winds).  I want to convert this
 band to 4 8BUI bands.

 So I create this user defined function to feed into my ST_MapAlgebraFnct
 single band version that takes pixel and a single user defined arg that
 will represent the band to map to. (http://www.postgis.org/documentation
 /manual-svn/RT_ST_MapAlgebraFct.html ).

 So looks something like:


 {{{
 CREATE OR REPLACE FUNCTION solar_band_mapper(pixel double precision,
 VARIADIC args TEXT[])
     RETURNS double precision
     AS $$ BEGIN
         RETURN CASE args[1] WHEN '1' THEN pixel WHEN '2' THEN CASE WHEN
 pixel BETWEEN 1000 and 5000 THEN 100 ELSE 0 EMD   WHEN '3' THEN ... END;

     END; $$
     LANGUAGE 'plpgsql' IMMUTABLE COST 1000;
 }}}


 I have my table of solar winds and I want to be able to do this


 {{{
 SELECT rid, ST_AddBand(array_agg(ST_MapAlgebraFct(rast,'8BUI',
 'solar_band_mapper(double precision,text[])'::regprocedure, i::text) ORDER
 BY i) ) As multi_band_rast
 FROM solar_winds CROSS JOIN generate_series(1,3) As i
 GROUP BY rid;
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1245#comment:5>
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