I have raster data stored in a PostgreSQL/PostGIS database. I need to create a summed raster from certain rasters.

Something like:

select sum(raw_data) as image from data where rid > 2 AND rid < 5; 

But this is not the correct function. What is?


1 Answer 1


Use ST_Union(rast, 'SUM')

Overlapping pixels will be summed into a new raster. Note there are also FIRST, MIN, MAX, COUNT, MEAN, RANGE options for the uniontype paramter.

  • Good to know. There was me thinking you needed MapAlgebra, hugely overcomplicating things as always. Mar 9, 2016 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.