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

Stephen Woodbridge woodbri at swoodbridge.com
Tue Aug 31 11:47:37 EDT 2010


On 8/31/2010 11:11 AM, Carmelo Terrasi wrote:
> 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(?,?, ... , ?);/

maybe something like:

     GDALRasterIO( pointerToBand, GF_Read, x, y, 1, 1,
                   &elevation, 1, 1, GDT_Float32,
                   0, 0 );

-Steve

> 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.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list