[gdal-dev] DTED Elevations with Java and gdal
Frank Warmerdam
warmerdam at pobox.com
Wed Oct 19 21:08:34 EDT 2011
On Wed, Oct 19, 2011 at 1:23 PM, Roger Viton <wsureshoot at 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, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Software Developer
More information about the gdal-dev
mailing list