Name

ST_AsRasterAgg — Aggregate. Renders PostGIS geometries into a new raster.

Synopsis

raster ST_AsRasterAgg(geometry geom, double precision val, raster ref, text pixeltype, double precision nodataval, text uniontype, boolean touched);

Descripción

Returns a single-band raster containing the rendered version of all incoming geometries, each with its associated value.

Availability: 3.6.0

Ejemplos

WITH inp(g,v) AS (
        VALUES
                ( ST_Buffer(ST_MakePoint(10,0), 10), 1 ),
                ( ST_Buffer(ST_MakePoint(20,0), 10), 2 )
),
agg AS (
        SELECT ST_AsRasterAgg(
                g,
                v,
                ST_MakeEmptyRaster(0,0,0,0,1.0),
                '8BUI',
                99,
                'SUM',
                true
        ) r
        FROM inp
)
SELECT
        ST_Width(r) w,
        ST_Height(r) h,
        ST_Value(r,'POINT(5 0)') v5_0,
        ST_Value(r,'POINT(15 0)') v15_0,
        ST_Value(r,'POINT(25 0)') v25_0
FROM agg;
 w  | h  | v5_0 | v15_0 | v25_0
----+----+------+-------+-------
 30 | 20 |    1 |     3 |     2
(1 row)