[postgis-users] PostGIS - Simple Raster Point Query

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Fri Dec 14 16:18:57 PST 2012


Maybe it would be better to describe more generally what you are trying to achieve. Most complex processing can normally be achieved in one complex query.

PostgreSQL should cache what was loaded in previous queries so that it does not necessarily reload tiles at each query.

Pierre

> We query the points on the line with one query for each point. This could be
> optimised like this:
> SELECT ST_AsText(
> ST_line_interpolate_point(
> ST_GeometryFromText('LINESTRING(0 0,0 1,1 1)'), CAST(p AS numeric)/10
> )
> )
> FROM generate_series(1,10) p;
> to get all points. But this is still requiring one query for each point on the line. I
> suspect, if we were to query all points at once, there will have to be less reading
> of the raster, because the points are likely to be on the same tile. However, I do
> not know how to achieve that. Can I somehow intersect the line with the raster
> and query all the points above?
> 
> Any hints would be greatly appreciated.
> 
> Thanks,
> Tim
> 
> Tim-Hinnerk Heuer
> 
> Twitter: @geekdenz
> 
> Blog: http://www.thheuer.com <http://www.thheuer.com/>
> 
> 
> 
> On 9 December 2012 20:36, Tim-Hinnerk Heuer <th.heuer at gmail.com> wrote:
> 
> 
> 	Hi Pierre,
> 
> 	Great! Thank you so much, that worked!
> 
> 	You're a genius!
> 
> 	In case you are wondering. That point is Mount Ruhapehu and it gave
> me the answer: 2611.7314453125 (m) which is indeed correct.
> 
> 	Kind regards,
> 	Tim
> 
> 	Tim-Hinnerk Heuer
> 
> 	Twitter: @geekdenz
> 
> 	Blog: http://www.thheuer.com <http://www.thheuer.com/>
> 
> 
> 
> 	On 9 December 2012 20:24, Pierre Racine
> <Pierre.Racine at sbf.ulaval.ca> wrote:
> 
> 
> 		SELECT ST_Value(rast,ST_SetSRID(ST_Point(1821416, 5649720),
> 2193))
> 		FROM nzdem3
> 		WHERE  ST_Intersects(rast,ST_SetSRID(ST_Point(1821416,
> 5649720), 2193))
> 
> 



More information about the postgis-users mailing list