[postgis-users] Extracting cell values into a matrix

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Fri Jun 29 12:46:29 PDT 2012


> Hi, I need to develop a tool that is able to connect with PostGIS and extract
> the cell values from a raster stored in it creating a matrix with them. It
> could be done with queries launched from that tool, using ST_Value(), for
> each cell, but the number of queries would be huge.

You would better be creating a polygon encompassing the pixels you want and ST_Clip the raster to this polygon and then get all the values with (ST_PixelAsPolygons()).val,  (ST_PixelAsPolygons()).x, (ST_PixelAsPolygons()).y

But could you explain what you intent to do with the values of the matrix? Maybe there is a simpler way to do it in SQL...

Maybe just adding a parameter to ST_Neighborhood stating that the neighbourhood should be a square instead of a circle would also do what you want. Bborie?

Pierre


More information about the postgis-users mailing list