[postgis-users] Creating a multiband raster from 3 single band rasters

Bborie Park dustymugs at gmail.com
Sun Jul 7 21:38:13 PDT 2013


Check out the last example (Multi-band versions) of ST_AddBand().

http://postgis.refractions.net/documentation/manual-svn/RT_ST_AddBand.html

-bborie


On Sun, Jul 7, 2013 at 8:43 PM, Mark Wynter <mark at dimensionaledge.com>wrote:

> I'm hoping someone can suggest a way of efficiently combining 3 individual
> (but concordant) single band rasters into single raster having 3 bands?
>  We're working with PostgreSQL9.1, PostGIS2.1Beta.
>
> The starting point is a single tiled raster with 3 bands representing RGB
> values.
>
> Let's say we perform some color smoothing on each of the RGB bands using
> mapalgebra.
>
> CREATE TABLE resample_myrastertable_b1 AS
> SELECT rid, st_mapalgebrafctngb(rast, 1, '8BUI', 5, 5,
> 'st_mean4ma(float[][],text,text[])'::regprocedure, 'ignore', NULL) as rast
> FROM original_rastertable;
>
> CREATE TABLE resample_myrastertable_b2 AS
> SELECT rid, st_mapalgebrafctngb(rast, 2, '8BUI', 5, 5,
> 'st_mean4ma(float[][],text,text[])'::regprocedure, 'ignore', NULL) as rast
> FROM original_rastertable;
>
> CREATE TABLE resample_myrastertable_b3 AS
> SELECT rid, st_mapalgebrafctngb(rast, 3, '8BUI', 5, 5,
> 'st_mean4ma(float[][],text,text[])'::regprocedure, 'ignore', NULL) as rast
> FROM original_rastertable;
>
> This gives us 3 single-band results rasters.
>
> How do we now join the individual smoothed RGB "results" rasters into a
> single multiband "results" raster?   We'd also like to add a 4th band to
> the "results" raster based on say a calculation which references the
> smoothed values in bands 1-3.
>
> I'm getting reasonably comfortable writing MapAlgebra callback
> expressions.   Its more a case of how do we efficiently handle table
> operations (e.g. appending single band raster outputs) each time we perform
> some MapAlgebra?
>
> Any suggestions and or a simple worked example would be most appreciated.
>
> Many thanks
>
> Mark
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130707/e586c7c3/attachment.html>


More information about the postgis-users mailing list