Hi Linda,

> But what about the x and y coordinates. I need the world coordinates. Until
> now I did not found any method to get them. The only method seems to be to
> transform grid coordinates to world coordinates. But I think that this is
> very unnecessary because the world coordinates are in the gridCoverage2D.

The world coordinates are not "in" the coverage in the sense of fields
attached to grid cells. Rather, the internal coverage methods work in
image space (grid coordinates), translating to and from world
coordinates as required.

You can accomplish what you want without needing to use JAI code
directly. Here's one way...

        GridGeometry2D gg = cov.getGridGeometry();
        final int numBands = cov.getNumSampleDimensions();
        double data[] = new double[numBands];
        Rectangle gridBounds = gg.getGridRange2D().getBounds();
        for (int y = gridBounds.y, ny = 0; ny < gridBounds.height; y++, ny++) {
            for (int x = gridBounds.x, nx = 0; nx < gridBounds.width;
x++, nx++) {
                GridCoordinates2D gridCoord = new GridCoordinates2D(x, y);
                DirectPosition worldCoord = gg.gridToWorld(gridCoord);
                cov.evaluate(gridCoord, data);
                // just writing to console in this example
                System.out.printf("%.4f %.4f",
worldCoord.getOrdinate(0), worldCoord.getOrdinate(1));
                for (int band = 0; band < numBands; band++) {
                    System.out.printf(" %.4f", data[band]);
                }
                System.out.println();
            }
        }

Hope this helps,

Michael

------------------------------------------------------------------------------
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to