[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-users] getting elevation of a coordinate from a geotiff
|
Hi,
I am trying to read the elevation of the coordinate the mouse cursor is located. I have not been successful although I am trying for a couple of days.
I am using Udig 1.2m6 on a windows machine, customizing the Distancetool example. I have opened a srtm30(bathymetry) geotiff.
I have tried the following code to get the gray scale byte value of the mouse position
---------------------------
public float getElevationOfPoint(int x, int y){
int[] intarr = null;
RenderedImage image = getContext().getRenderManager().getImage();
Raster raster = image.getData();
DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
PixelInterleavedSampleModel sampleModel = (PixelInterleavedSampleModel) raster.getSampleModel();
int[] samples = sampleModel.getPixel(x, y, intarr, dbb);
return samples[0];
}
---------------------
But this just returns value between 0-255 as expected. How can I get the real elevation at the mouse cursor point?
Any pointers?
Best regards,
--
Devrim Baris Acar