Opened 13 years ago

Closed 6 days ago

#1247 closed enhancement (fixed)

[raster] ST_AsRaster aggregate function

Reported by: robe Owned by: strk
Priority: medium Milestone: PostGIS 3.6.0
Component: raster Version: master
Keywords: Cc:

Description (last modified by strk)

Pierre,

Not sure if this is what you had in mind when you said "Burn In" function in your talk. A common need I have which I am sure is that of many BI analysts is the need to show simple thematic maps in reports.

What came to mind to me was an aggregate ST_AsRaster function that takes a set of geomval rows (or multicolumn geom, value) and builds a raster. Basically a reverse of the ST_DumpAsPolgons function.

This would make it trivial to do a query such as

SELECT ST_AsPNG(ST_AsRaster(gval),300,300) As mymap
FROM (SELECT ROW(ST_Union(geom), SUM(pop))::geomval As gval
FROM sumregion
GROUP BY region_name) As foo;

Which is big considering many report writers allow their picture box controls to be bound to query fields. We might have a new crowd of BI analysts looking to get a piece of PostGIS action.

Change History (17)

comment:1 by robe, 13 years ago

Description: modified (diff)

comment:2 by robe, 13 years ago

Description: modified (diff)

comment:3 by pracine, 13 years ago

This is ST_UnionToRaster as planned in Objective FV.19 of the future specs:

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

It is dependent on the two raster version of ST_Mapalgebra which is being developed.

comment:4 by pracine, 13 years ago

Milestone: PostGIS Raster FuturePostGIS Future
Summary: ST_AsRaster aggregate function[raster] ST_AsRaster aggregate function

comment:5 by robe, 7 years ago

Milestone: PostGIS FuturePostGIS Fund Me

Milestone renamed

comment:6 by strk, 3 weeks ago

Component: postgisraster
Milestone: PostGIS Fund MePostGIS 3.6.0
Owner: changed from pramsey to strk
Status: newassigned

comment:7 by strk, 3 weeks ago

Description: modified (diff)

comment:8 by strk, 9 days ago

FV.19 signature of ST_BurnToRaster seems to be missing a band argument, also it recommends using ST_AsRaster(geometry, rast, value, 'CROP') but I don't see any signature like that existing ?

What's the policy on updating that specification ?

comment:10 by strk, 9 days ago

I'll keep PR-232 for ST_BurnToRaster (as per FV.19) but for this ticket's goal I'll use another PR to wrap ST_Union (raster version) so the aggregate is faster. This matches the original request by Regina.

comment:11 by strk, 9 days ago

Comments welcome on this proposed interface for the aggregate:

raster ST_AsRasterAgg(
  geomval set,
  raster ref,
  text pixeltype,
  double precision nodataval=0,
  text uniontype='LAST',
  bool touched=false
);

comment:12 by robe, 9 days ago

that works for me.

comment:14 by strk, 6 days ago

I'm not sure I like "geomval" single argument rather than two distinct "geom" and "val" arguments, I don't see the benefit of that…

comment:15 by strk, 6 days ago

I went with the extended version:

ST_AsRasterAgg(
 geom geometry,
 val float8,
 ref raster,
 pixeltype text,
 nodataval float8,
 uniontype text,
 touched boolean
)

The aggregate burns each incoming geometry to a raster having the origin and scale specified by the reference raster and unions it to the state raster using the specified uniontype.

If we all agree on the signature I'll proceed with documentation

comment:16 by strk, 6 days ago

Well I went ahead and wrote documentation too: https://git.osgeo.org/gitea/postgis/postgis/pulls/234

comment:17 by Sandro Santilli <strk@…>, 6 days ago

Resolution: fixed
Status: assignedclosed

In 2b7380ec/git:

Add ST_AsRasterAgg aggregate

Closes #1247
Includes regress test and documentation

Note: See TracTickets for help on using tickets.