Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-users] Getting raster data from a wms layer

Hi,
I have setup a geoserver which serves nasa srtm30 bathymetry elevation data(geotiff)  in pyramids.

I have added this as a wms layer to udig but stuck on the point to read the raster value on a mouse clicked point.
For a local geotiff file, the following code seems to work ok but I dont know what should I do for a wms layer as its georesource is not of GridCoverage2D class.

What should I do to access raster data values on a  wms (or wmsc) layer?

Best regards,
Devrim Baris Acar

---------------------------
//works for local geotiff
public float getElevationOfPoint2(int x, int y) {

        ILayer layer = getContext().getMapLayers().get(0);
        GridCoverage2D geoRes = null;
        try {
            geoRes = (GridCoverage2D) layer.getGeoResource().resolve(
                    GridCoverage.class, new NullProgressMonitor());
        } catch (IOException e) {
            e.printStackTrace();
        }

        DirectPosition dp = new DirectPosition2D(geoRes.getCoordinateReferenceSystem(), start.x, start.y); // start is of type Coordinate
        int[] evaluate = (int[]) (geoRes.evaluate(dp));
        return new Float(evaluate[0]);

    }
---------------------------




Back to the top