On Wed, Oct 19, 2011 at 1:23 PM, Roger Viton <wsuresh...@fastmail.fm> wrote: > There have been other threads on this topic. The threads seem to die with no > clear solution presented. > > Does anyone have a Java example on how to get elevations from a DTED file? > > > org.gdal.gdal.Dataset dataset = org.gdal.gdal.gdal.Open(<some dted file>, > org.gdal.gdalconst.gdalconst.GA_ReadOnly); > > > With an x y point how can the elevation be derived? > > > We have been able to run GDALtest.java against a DTED file with no problem. > There does not seem to be any reference to any elevation in DTEDtest.java > > Just want to get the elevation at a point.
Roger, There is nothing special about a DTED file compared to other raster files. The only thing to keep in mind is to load the elevation into a buffer with a better type than Byte. The gdal/swig/java/apps/GDALTestIO.java shows an example of reading into a Float32 buffer. You have not been specific about the coordinate system of your x y point so it is hard to be specific. As Kyle suggests the gdallocationinfo program does what you want, but in C++ with some variations. It should be instructive even if you don't want to do it in C++. Assuming your x and y are in longitude and latitude, then you should just need to use the geotransform from the file to transform the x/y into pixel/line coordinates suitable for use with the RasterIO() method. If you only want one pixel then just read into a 1x1 buffer. Best regards, -- ---------------------------------------+-------------------------------------- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | Geospatial Software Developer _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev