​Hi there,

I am applying an affine transform to a grid-coverage via ​coverage
processor + org.geotools.coverage.processing.operation.Affine:

----------------------------------------------------------------------------
   File img = new File("/path/to/image");
   GridCoverage2D imgCoverage =
GridFormatFinder.findFormat(img).getReader(img).read(null);
   Interpolation INTERP =
Interpolation.getInstance(Interpolation.INTERP_NEAREST);
   AffineTransform affTr = new AffineTransform();
   affTr.translate(X, Y);
   [...]
   Operation affOp = new Affine();
   ParameterValueGroup param = affOp.getParameters();
   param.parameter("Source").setValue(imgCoverage);
   param.parameter("transform").setValue(affTr);
   param.parameter("Interpolation").setValue(INTERP);
   GridCoverage2D transformedCoverage = (GridCoverage2D)
COV_PROCESSOR.doOperation(param);
----------------------------------------------------------------------------

I can see that, although the affine transform is attached to the grid
geometry of the coverage, the geo-envelope does not change with respect to
the source grid-coverage, hence e.g. translations do not have any effect on
the map. Rotations are visible, but again dimensions get smaller to fit
into the source envelope.

Is there a way let the geo-bounds of the processed coverage correctly
follow the underlying image transformations?

Thanks for any comment,
-Piero


PS In the meantime I am obtaining the desired effect on map by changing the
CRS of the coverage to a fitted system (DerivedCRS). I am not yet sure
whether this is a worse solution performance-wise, I believe the burden on
the renderer should be the same (affine tr. at reprojection or affine tr.
on grid2world), but I'll make comparison as soon as the coverage-processor
option above is working fine.

----------------------------------------------------------------------------
    DerivedCRS derivedCRS = new DefaultDerivedCRS("derivedCRS", originalCRS,
        ProjectiveTransform.create(affTr),
        originalCRS.getCoordinateSystem());
    GridCoverage2D transformedCoverage = new
GridCoverageFactory().create("transformed",
        imgCoverage.getRenderedImage(),
        new ReferencedEnvelope(imgLayer.getBounds(), derivedCRS));
----------------------------------------------------------------------------
------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to