}
// Crop or Clip
final CropCoverage cropCoverage = new CropCoverage(); // TODO avoid creation
if (clip) {
// clipping means carefully following the ROI shape
clippedGridCoverage = cropCoverage.execute(reprojectedGridCoverage,
roiManager.getSafeRoiInTargetCRS(), progressListener);
} else {
// use envelope of the ROI to simply crop and not clip the raster. This is important since when
// reprojecting we might read a bit more than needed!
final Geometry polygon = roiManager.getSafeRoiInTargetCRS();