[postgis-users] raster query

Stephen Crawford src176 at psu.edu
Wed Nov 2 13:51:05 PDT 2016


Hi All,

I am hoping somebody can help me with a query.  I have a table of 
rasters where each record is date ("obs_date") and raster containing a 
risk value of 0  or 1.  My easy, successful query to accumulate the risk 
values over the previous 60 days is:

INSERT INTO accum_risk (obs_date, rast)
SELECT '1979-07-15', ST_Union(rast,'SUM')
FROM daily_risk
WHERE obs_date BETWEEN '1979-05-16' AND '1979-07-15';

My final goal--for which I am asking help--is similar to the above 
query, but it will reference another raster table.  This table has for 
each grid cell a value for the day of year (DOY) from which the 60 day 
accumulation should be made. Conceptually:

FOR EACH doy_cell IN doy_raster
SELECT ST_Union(rast,'SUM')
FROM daily_risk
WHERE obs_date BETWEEN doy-60 AND doy;

Any help is greatly appreciated.

Thanks,
Steve

-- 
Stephen Crawford
Center for Environmental Informatics
The Pennsylvania State University
src176 at psu.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20161102/479e4c0f/attachment.html>


More information about the postgis-users mailing list