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

Chaitanya kumar CH chaitanya.ch at gmail.com
Tue Aug 31 11:54:17 EDT 2010


Carmelo,

In the code n30.dt0 is some raster image file. Replace it with your image
path.
The array named 'data' was renamed to pippo. Correct that.

Refer to GDALDataset::GetGeoTransform() method at
http://www.gdal.org/classGDALDataset.html

Use GDALDataset::RasterIO() or GDALRasterIO while treating the pointer to a
double variable as the buffer (pData in the function definition).

On Tue, Aug 31, 2010 at 8:41 PM, Carmelo Terrasi
<terrasi.carmelo at gmail.com>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(?,?, ... , ?);*
>
>
> 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
>



-- 
Best regards,
Chaitanya kumar CH.
/tʃaɪθənjə/ /kʊmɑr/
+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100831/e88750cd/attachment.html


More information about the gdal-dev mailing list