Carmelo,<br><br>In the code n30.dt0 is some raster image file. Replace it with your image path.<br>The array named 'data' was renamed to pippo. Correct that.<br><br>Refer to GDALDataset::GetGeoTransform() method at <a href="http://www.gdal.org/classGDALDataset.html">http://www.gdal.org/classGDALDataset.html</a><br>
<br>Use GDALDataset::RasterIO() or GDALRasterIO while treating the pointer to a double variable as the buffer (pData in the function definition).<br><br><div class="gmail_quote">On Tue, Aug 31, 2010 at 8:41 PM, Carmelo Terrasi <span dir="ltr"><<a href="mailto:terrasi.carmelo@gmail.com">terrasi.carmelo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello everybody,<br><div>first of all my apologies cause I'm a newbie with this stuff...</div>
<div><br></div><div>I'm trying to build a function able to extract altitude from latitude and longitude as parameters.</div>
<div>Something like that: <b>double MyElevation(double lat, double lon)</b></div><div><b><br></b></div><div>I'm using Dted level 0 to get the elevation (I've already read this post: <a href="http://www.osgeo.org/pipermail/gdal-dev/2010-February/023457.html" target="_blank">http://www.osgeo.org/pipermail/gdal-dev/2010-February/023457.html</a> )</div>
<div>But I got lost... :(</div><div><br></div><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
<i><span style="font-size: x-small;">GDALAllRegister();<br></span></i><div><i><span style="font-size: x-small;">pointerToDataSet=(GDALDataset*) GDALOpen("n30.dt0", GA_ReadOnly);</span></i></div>
<div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div><div><i><span style="font-size: x-small;">double data[6];</span></i></div>
<div><i><span style="font-size: x-small;">double longitude, latitude;</span></i></div><div><i><span style="font-size: x-small;"><br></span></i></div><div><i><span style="font-size: x-small;">pointerToDataSet->GetGeoTransform(data);</span></i></div>
<div><i><span style="font-size: x-small;"><br></span></i></div><div><i><span style="font-size: x-small;">longitude=???;</span></i></div><div><i><span style="font-size: x-small;">latitude=???;</span></i></div>
<div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div><div><i><span style="font-size: x-small;">double x = (longitude - pippo[0]) / pippo[1];</span></i></div>
<div><i><span style="font-size: x-small;">double y = (latitude - pippo[3]) / pippo[5];</span></i></div><div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div>
<div><i><span style="font-size: x-small;">GDALRasterBand* pointerToBand;</span></i></div><div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div>
<div><i><span style="font-size: x-small;">pointerToBand=pointerToDataSet->GetRasterBand(1);</span></i></div><div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div>
<div><i><span style="font-size: x-small;">float *elevation;</span></i></div><div><span style="white-space: pre-wrap;"><i><span style="font-size: x-small;">        </span></i></span></div>
<div><i><span style="font-size: x-small;">pointerToDataSet->RasterIO(?,?, ... , ?);</span></i></div><div><div><i><span style="font-size: x-small;">pointerToBand->RasterIO(?,?, ... , ?);</span></i></div>
</div></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><div><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"></blockquote><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;">
</blockquote><div><br></div></div><div>I supposed I had to store elevation data into the buffer I created, I mean the float pointer.</div><div>I got confused among these:</div><div>- the file *.dt0 </div><div>- longitude and latitude </div>
<div>- parameters for RasterIO()</div><div><br></div><div>Every tips will be very appreciated, thanks a lot for your patience,</div><div>Regards,</div><div>Carmelo</div>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9494447584<br>17.2416N 80.1426E<br>