[postgis-users] postgis raster st_value

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue Feb 21 07:32:51 PST 2012


> Thank you.  It works great!  The following works for a single point against a
> single raster:
> 
> SELECT
> ST_Value(rast, ST_SetSRID(ST_Point(187251.0, 119422.0), 26957)) FROM geol1
> WHERE ST_Intersects(rast, ST_SetSRID(ST_Point(187251.0, 119422.0),
> 26957)::geometry, 1);

It will work even faster if you retile everything to smaller tiles and create an index on your raster column (which I have no doubt you did). You can use the new ST_Tile() plpgsql prototype to retile everything without reloading:

http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_tile.sql

It's a bit slow but can work overnight...

> Could anyone recommend the best way to query multiple rasters using the same
> point for each?  I've seen examples pulling multiple points from the same rasters
> but not the same point from multiple rasters.  I have about 10-20 rasters (geol2,
> geol3..) I need to find the value of at a single point.

If you have an application that want to do that often I would recommend to store all the tiles for all the layers in the same table with a column identifying the semantic of each set of tile. You then just do a query like you did, adding the point id and the semantic column. For each point you will get as many rows as you have layers. Transforming everything in a one multiple column row is another story: You have to JOIN the table with itself as many time as you have layers.

Pierre



More information about the postgis-users mailing list