[postgis-devel] ST_MapAlgebraExpr(): Raster aggregates?

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Nov 21 13:28:24 PST 2011


Tom,

ST_Union is.... Fixed! Thanks to Bborie.

Just update your source, create a fresh database (or get rid of the old MapAlgebra4Union) and execute everything up to the tests at the bottom of the file. Have a visual look at the test using OpenJump or QGIS (they were written for OpenJump with the ST_Asbinary() converting the vectorization of the result.)

Let us know about your tests. 

For those who might be interested ST_Union() is the prototype of a function aggregating overlapping rasters into a single raster. It does pretty much the same thing as the ST_Union(geometry) aggregate but for rasters. Since it is an AGGREGATE you can use GROUP BY to aggregate based on the value of a column. You have to specify how you want raster values to be aggregated. I implemented shortcuts to MAX, FIRST, LAST, COUNT, SUM, RANGE and MEAN, but you can define your own complex aggregator by defining a STATE expression, a TEMPORARY and a FINAL expression. Have a look at the specifications in 

http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03

And have fun!

Pierre

> -----Original Message-----
> From: postgis-devel-bounces at postgis.refractions.net [mailto:postgis-devel-
> bounces at postgis.refractions.net] On Behalf Of Tom van Tilburg
> Sent: Monday, November 21, 2011 5:05 AM
> To: PostGIS Development Discussion
> Subject: Re: [postgis-devel] ST_MapAlgebraExpr(): Raster aggregates?
> 
> Pierre,
> 
> Thanks a lot for pointing me out this.
> I've looked in to the plpgsql code but I'm afraid my current knowledge (or time)
> doesn't allow me to contribute code.
> 
> However, I tested the prototype of ST_Union. It appears to be rather buggy
> (typo's). Has it ever been applied/tested?
> (eg: 'ERROR:  parameter name "p_nodata1expr" used more than once. '
> seems to be copy paste error.)
> 
> Chrs,
>   Tom
> 
> On 18-11-2011 16:54, Pierre Racine wrote:
> > I would even suggest you write a plpgsql prototype for ST_UnionToRaster()
> based on the specifications.... ...if you have time for sure.
> >
> > I would be glad to add it in the plpgsql/script on the trunk. It then becomes the
> reference for a future C implementation.
> >
> > Pierre
> >
> >> -----Original Message-----
> >> From: postgis-devel-bounces at postgis.refractions.net
> >> [mailto:postgis-devel- bounces at postgis.refractions.net] On Behalf Of
> >> Pierre Racine
> >> Sent: Friday, November 18, 2011 10:39 AM
> >> To: PostGIS Development Discussion
> >> Subject: Re: [postgis-devel] ST_MapAlgebraExpr(): Raster aggregates?
> >>
> >> Tom,
> >>
> >> Look at the plpgsql prototype of ST_Union(raster) in
> >>
> >> http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st
> >> _union.sql
> >>
> >> Have a look also at the specifications of ST_UnionToRaster(geometry,
> >> val) in
> >>
> >> http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03
> >>
> >> Everything is based on ST_MapAlgebraExpr(raster, raster, expr) and
> >> should do exactly what you want.
> >>
> >> It should be ok for producing low resolution raster as our first
> >> implementation of ST_MapAlgebraExpr(raster, raster) process pixel by
> >> pixel. Higher resolution will need an optimized version of
> >> ST_MapAlgebra(raster, raster) copying large areas of raster values
> >> when possible (it is exactly what we need for unioning two rasters
> >> efficiently). We started to make a plpgsql prototype for this
> >> optimized version but it is not finished
> >> (http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/s
> >> t_mapalge bra_optimized.sql). I guess we will need some funding to
> >> make it happen...
> >>
> >> Let me know about your experiments...
> >>
> >> Pierre
> >>
> 
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list