I am testing the PostGIS map algebra (ST_MapAlgebra) on two different raster tables.

Each table contains a single image/row. They have the same SRID but different, overlapping extents and different ground resolution. What I did was:

SELECT ST_MapAlgebra(t1.rast,t2.rast
        ,'([rast1]+0.001)/([rast2]+0.001)') AS rast
FROM t1, t2 

And I got an error saying that

rt_raster_iterator: The set of rasters provided (custom extent included, if appropriate) do not have the same alignment

Now, what I want to do is to resample t1.rast and t2.rast to their common area (i.e. intersection) at the higher resolution of the two rasters.

Is there a function for this in PostGIS (2.1+)? and, if not, how should I go about making such a query?

I looked at ST_REsample, and it seems that it can only sample one image to the reference grid of another. Also, the documentation says that it does not handle SRID since PostGIS 2.1.


1 Answer 1



SELECT ST_MapAlgebra(t1.rast,ST_Resample(t2.rast, t1.rast)
        ,'([rast1]+0.001)/([rast2]+0.001)') AS rast
FROM t1, t2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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