[postgis-users] Creating a multiband raster from 3 single band rasters
Mark Wynter
mark at dimensionaledge.com
Sun Jul 7 20:43:49 PDT 2013
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
More information about the postgis-users
mailing list