You will need to know a bit more about your grid coverage - see you
how are working with the raster directly? You should be useig the
GeoTools GridCoverage api which should help you read out all kinds of
information (it consults the raster metadata in order to know how to
process bytes to height or categores or whatever).
For these kind of data questions you may wish to ask on the geotools-
users list? Personally I am not very good at hacking away at raster
data and others will be in a better position to answer your question.
Jody
On 28/08/2009, at 11:31 PM, Devrim Baris Acar wrote:
> 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
>
> _______________________________________________
> udig-users mailing list
>
[hidden email]
>
http://lists.refractions.net/mailman/listinfo/udig-users_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users