Hello,

If you have created a GridCoverage2D object from your image you can
convert grid positions to world positions as in this example...

GridCoverage2D cov = ...
GridGeometry2D gg = cov.getGridGeometry();
GridEnvelope2D gridEnv = gg.getGridRange2D();

GridCoordinates2D coord = new GridCoordinates2D();
for (int gy = gridEnv.y, ny = 0; ny < gridEnv.height; ny++, gy++) {
    for (int gx = gridEnv.x, nx = 0; nx < gridEnv.width; gx++, nx++) {
        DirectPosition worldPos = gg.gridToWorld(coord);

        System.out.printf("grid pos (%d, %d) - world pos (%.2f %.2f) \n",
                gx, gy, worldPos.getOrdinate(0), worldPos.getOrdinate(1));
    }
}

If you want more control over exactly how the grid (pixel) coordinates
are converted to world coordinates, e.g. pixel centre vs corner, you
do this via the transform returned by the getGridToCRS2D method:

http://docs.geotools.org/stable/javadocs/org/geotools/coverage/grid/GridGeometry2D.html#getGridToCRS2D(org.opengis.metadata.spatial.PixelOrientation)

You can get the value for a location using either a grid position or a
world position with the various evaluate methods. See the javadocs for
these:
http://docs.geotools.org/stable/javadocs/org/geotools/coverage/grid/GridCoverage2D.html

Hope this helps,
Michael

On 11 May 2011 21:35, vashisthg <[email protected]> wrote:
> Hi friends,
> I am a new user of geotools.
> I want to get the coordinate values and value(Height, as the image file is a
> raster) of every pixel, preferably with a for loop or anything. I need to
> change the x y and z values acc to a criteria which i have already coded.
>
> Thanks and Regards
> Gaurav Vashisth
>
> M.Tech Geomatics Engineering
> Indian Institute of Technology Roorkee
> India
>
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/get-x-y-and-values-of-every-pixel-new-user-tp6351475p6351475.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to