Hi Linda, Jon,

Sorry - didn't realize you were still stuck !  I hadn't been following
the last few messages on this thread.

If what you want to do is retain the coverage's world bounds but alter
its resolution (ie. its grid bounds) you can do as in the code snippet
below. Note that I'm not reprojecting in this example, though you can
do that at the same time by setting the "CoordinateReferenceSystem"
parameter.

/*
 * Resample a grid to half the current resolution
 */
GridCoverage2D cov = ...

DefaultProcessor processor = new DefaultProcessor(null);

ParameterValueGroup parameters =
        processor.getOperation("Resample").getParameters();

parameters.parameter("Source").setValue(cov);

// interpolation can be NearestNeighbor, Bilinear or Bicubic
parameters.parameter("InterpolationType").setValue("NearestNeighbor");

GridGeometry2D curGridGeom = cov.getGridGeometry();
Envelope curWorldEnv = curGridGeom.getEnvelope2D();

GridEnvelope2D curGridEnv = curGridGeom.getGridRange2D();

// create new GridGeometry with half as many cells
GridEnvelope2D newGridEnv = new GridEnvelope2D(
        curGridEnv.x, curGridEnv.y, curGridEnv.width / 2,
curGridEnv.height / 2);
GridGeometry newGridGeom = new GridGeometry2D(newGridEnv, curWorldEnv);

parameters.parameter("GridGeometry").setValue(newGridGeom);
GridCoverage2D resampledCov = (GridCoverage2D)
processor.doOperation(parameters);

Does this help ?

Michael

------------------------------------------------------------------------------

_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to