[postgis-devel] Geometry->Raster (rendering)

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Wed Jan 26 07:47:07 PST 2011


>today Norman was reporting a use case which seemed
>to call for raster rendering: creation of an "heat" map,
>that is a raster showing vectorial features occurrences.
>
>My idea was you'd initialize an empty raster and iteratively
>render each vector on top, with each vector adding some value
>to the pixels.
>
>Now, I was looking in the RASTER plan for such a "render-to-raster"
>function but haven't found one. With the CHIP type I did make this
>kind of interface:

This is planned as ST_UnionToRaster() which is an aggreate function "burning" a set of geometries to a single final raster. I still have to finalize and add the specification of this function to the wiki.

Grosso modo this function:

-Rasterize each geometry to a new raster
-ST_Union each of these rasters into a single one (the aggregate) using a set of three expressions: "initial", "middle" and "final" very similar to the INITCOND, FINALFUNC and SFUNC of a SQL aggregate function. Those three functions let you control very precisely how to burn the new values and are passed in order, during the aggregation process, to ST_MapAlgebra(rast1, rast2, expression).

So this function is dependent on:

- ST_AsRaster
- the two raster version of ST_MapAlgebra
- ST_Union

You can see plpgsql prototypes of those three functions in

postgis-trunk\raster\scripts\plpgsql\

They might however be broken right now. The dependency look a bit eavy but you can do an amazing number of things (almost everything) with those three working together.

I prefer this approach than writing very specific functions often reinventing the wheel.

Pierre





More information about the postgis-devel mailing list