[postgis-users] Efficient ways to query PostGIS Raster pixel values using Intersects

Andrew Hill andrew at vizzuality.com
Mon Dec 12 14:15:17 PST 2011


Hi Bborie,

As far as I can tell, ST_MapAlgebra requires the same grid alignment and
every other aspect? If so, this wouldn't fit use-cases where resampling is
needed. Your code does not work for me. I get the following error,

ST_MapAlgebra: Provided raster do not have the same alignment. Aborting

I worked to figure out what was going on and went through some iterations.
As far as I can figure out, ST_MapAlgebra(rast,rast) requires two tiles of
the exact same dimensions and proportions? So the following,

SELECT ST_MapAlgebra(rast, ST_AsRaster(ST_Intersection(ST_Envelope(rast),
tg),rast), 'rast1') FROM marso CROSS JOIN
GEOMETRYFROMTEXT('MULTIPOLYGON(((10 10, 10 0, 0 0, 0 10, 10 10)))',4326) tg
WHERE ST_Intersects(rast,GEOMETRYFROMTEXT('MULTIPOLYGON(((10 10, 10 0, 0 0,
0 10, 10 10)))',4326))

Takes my bounding box, crops it to only portion that is within a tile, and
then tries to ST_MapAlgebra, but will fail with the same error as above.
However, this one works fine,

SELECT ST_MapAlgebra(rast, ST_AsRaster(ST_Envelope(rast), rast), 'rast1')
FROM marso LIMIT 1

I assume because the tiles are the exact same.

Thanks,

Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20111212/137cf8d5/attachment.html>


More information about the postgis-users mailing list