// create a gridcoverage from the tile image
Envelope bounds = tile.getBounds();
GridCoverageFactory factory = new GridCoverageFactory();
ReferencedEnvelope ref = new ReferencedEnvelope(bounds.getMinX(), bounds.getMaxX(),
bounds.getMinY(), bounds.getMaxY(), crs);
GridCoverage2D coverage = (GridCoverage2D) factory.create(
"GridCoverage", tile.getBufferedImage(), ref); //$NON-NLS-1$
Envelope2D coveragebounds = coverage.getEnvelope2D();
// bounds of tile
Envelope tilebBounds = new Envelope(coveragebounds.getMinX(), coveragebounds.getMaxX(),