I've used the ReadRaster method with a short array and it working perfectly fine, the elevation data recovered are correct.
Thanks for your advice :) Alex Barféty -----Message d'origine----- De : Even Rouault [mailto:[email protected]] Envoyé : mercredi 28 mars 2012 10:23 À : AlexRNL Cc : [email protected] Objet : Re: [gdal-dev] Interpretation of DTED elevation data Selon AlexRNL <[email protected]>: > Hi everyone! > > > I have been trying to extract elevation data from a DTED file using > GDAL (in Java). The file being loaded is of level 0 precision and > seems to be correct as an import into Global Mapper is rendering the expected result. > > > I managed to retrieve the image data but I don't know to transform > those values into a altitude in meters. > > > According to the DTED format specification, the elevation values are > supposed to be two-bytes integer in meters. But, when using the > http://www.gdal.org/java/org/gdal/gdal/Band.html#ReadRaster_Direct(int > , int, int, int, int, int, int, java.nio.ByteBuffer) ReadRaster_Direct > method, the buffer retrieved is supposed to be composed of Int16 > number but when i'm converting the raw data (bytes) into a short array > i'm getting all sorts of value which doesn't make a lot of sense. The > range of the elevation is spanning from 1 to 65286! > > > Is there a conversion that i'm missing? How do I get the meter value > from the raster returned by GDAL? You should make sure to request with buf_type = gdalconst.GDT_Int16. Then iterating the buffer with getShort() should deliver the expected values. Otherwise use the version of ReadRaster() that accepts a short[]. That will be simpler to use. The benefit of using ByteBuffer instead standard Java arrays only appears with *huge* arrays > > > I've been searching for a while but it doesn't seem like anyone has > that kind of problem... > > > Thanks in advance for any information that may help me :) > > Alex. > > -- > View this message in context: > http://osgeo-org.1560.n6.nabble.com/gdal-dev-Interpretation-of-DTED-elevatio n-data-tp4663511p4663511.html > Sent from the GDAL - Dev mailing list archive at Nabble.com. _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
