[gdal-dev] Extract elevation from (latitude, longitude)

Carmelo Terrasi terrasi.carmelo at gmail.com
Wed Sep 1 06:15:55 EDT 2010


OK, I got it, it works, thank you so much!!!

2010/8/31 J Luis <jmfluis at gmail.com>

>  Carmelo,
>
> In GMT with GDAL support that is trivial to do using the grdtrack program.
>
> Joaquim Luis
>
>
> Hello everybody,
> first of all my apologies cause I'm a newbie with this stuff...
>
>  I'm trying to build a function able to extract altitude from latitude and
> longitude as parameters.
> Something like that: *double MyElevation(double lat, double lon)*
> *
> *
> I'm using Dted level 0 to get the elevation (I've already read this post:
> http://www.osgeo.org/pipermail/gdal-dev/2010-February/023457.html )
> But I got lost... :(
>
>  *GDALAllRegister();
> *
> *pointerToDataSet=(GDALDataset*) GDALOpen("n30.dt0", GA_ReadOnly);*
> * *
> *double data[6];*
> *double longitude, latitude;*
> *
> *
> *pointerToDataSet->GetGeoTransform(data);*
> *
> *
> *longitude=???;*
> *latitude=???;*
> * *
> *double x = (longitude - pippo[0]) / pippo[1];*
> *double y = (latitude - pippo[3]) / pippo[5];*
> * *
> *GDALRasterBand* pointerToBand;*
> * *
> *pointerToBand=pointerToDataSet->GetRasterBand(1);*
> * *
> *float *elevation;*
> * *
> *pointerToDataSet->RasterIO(?,?, ... , ?);*
>  *pointerToBand->RasterIO(?,?, ... , ?);*
>
>
>  I supposed I had to store elevation data into the buffer I created, I
> mean the float pointer.
> I got confused among these:
> - the file *.dt0
> - longitude and latitude
> - parameters for RasterIO()
>
>  Every tips will be very appreciated, thanks a lot for your patience,
> Regards,
> Carmelo
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100901/1bfcf7ae/attachment.html


More information about the gdal-dev mailing list