Opened 12 years ago
Last modified 7 years ago
#2281 new enhancement
multiband raster burning (braindump)
Reported by: | strk | Owned by: | dustymugs |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS Fund Me |
Component: | raster | Version: | master |
Keywords: | Cc: |
Description
With a "datacube" use case in mind I've been thinking to use a raster to incrementally aggregate values onto its bands.
For that to be effective I was thinking that the concept of "geomval" wouldn't be enough in that for each geometry I'd have multiple values (one for each field to be aggregated).
This ticket is to think about a way to burn a geometry to multiple bands at once.
Note that for my use case there would also need to possibly be a different operations for different bands. A simple example is I want a count of hits and a sum of values (two bands). That way I can compute the average in a second stage, when I'm done burning all records.
Change History (4)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
1) There is already a variant of ST_AsRaster() that takes many values and produce a multiple band raster.
2) To aggregate many geometries values into a single band you must use the right multiband variant of ST_Union(). You normally use 'LAST" or 'MEAN' to determine the value of overlapping pixels.
3) To aggregation multiple band together it's ST_Union again with the 'MEAN' or 'COUNT' argument.
ST_UnionToRaster will only be a wrapper around ST_AsRaster() and ST_Union(). So the combination of 1) and 2)…
Does this fullfill your needs?
Another way is to use ST_MapAlgegra with a custom function that would do a query on the vector coverage for every pixel of a pre georeferenced raster. That is way more flexible, but a bit slower (my guess is that this is still faster than ST_Union for huge rasters). See my blog.
comment:3 by , 12 years ago
From what strk was saying I thought he was looking for an
ST_Union (that for each band could take a different function MEAN, COUNT etc because he wants one band to be MEAN, one to be COUNT, and one to be LAST for example and untop of that could take user defined behavior like ST_MapAlgebra (essentially an aggregrate form of ST_MapAlgebra).
As I recall right now though 2.1 ST_Union is multi-band it only takes one operation and in fact only if you choose LAST is it really multiband.
and on top of that he could apply directly to geometries. So ya the ST_AsRaster wrapper is one part of that to convert his geomval[] fantasy into a raster.
Not that the map algebra expression part thingy of this is very similar to Pierre's spec
http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking03
FV.19 - ST_BurnToRaster and ST_UnionToRaster functions