[gdal-dev] query raster values by xy-location

Dane Springmeyer blake at hailmail.net
Fri Sep 26 13:03:25 EDT 2008


Hi Andi,

I had a similar task where I needed to find the elevation value from a  
geotiff at the upstream and downstream points of a river line segment.

This thread sums up my approach, based on a kick start from helpful  
postgis users:

http://postgis.refractions.net/pipermail/postgis-users/2008-August/020869.html

You'll see within the thread that I link to the code in a google code  
svn repo. I think you'll be most interested in the code around line 61  
of the raster lookup script here:

http://code.google.com/p/dbsgeo/source/browse/trunk/postgis/hydro_model/scripts/elevation_lookup.py#61

I'd be interested if there is a simpler and faster way to approach  
this issue of where to put the values once you've read them  
(particularly for the database access since I was needing to go back  
to postgis with the looked-up values), if anyone has ideas. What I  
found was that writing out a sql insert statement was faster than  
hitting the database with updated queries during the lookup routine,  
but I may not have been using the psycopg2 driver in the most optimal  
way.

Anyway, hope that helps.

Cheers,

Dane

On Sep 26, 2008, at 5:55 AM, Andruit at gmx.de wrote:

> Hello,
>
>
> I have an ESRI ascii raster and would like to get the raster values  
> at defined x y locations.
> At the moment I am capable to load the Raster Dataset and can  
> perform several operations like querying the  Min/Max values, the  
> origin, the pixelsize and so on....
>
> But is there a function to get the cell value of a raster at a  
> certain location (x y)????
>
> Has anybody done this before?
>
> Thanks
>
> Andi
> -- 
> GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
> Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list