}
// creating geotiff metadata
final CRS2GeoTiffMetadataAdapter adapter = new CRS2GeoTiffMetadataAdapter(crs);
final GeoTiffIIOMetadataEncoder metadata = adapter.parseCoordinateReferenceSystem();
// setting georeferencing
setGeoReference(crs, metadata, tr, range,retainAxesOrder);
// handling noData
final double inNoData = CoverageUtilities.getBackgroundValues((GridCoverage2D) gc)[0];
if (!Double.isNaN(inNoData))
metadata.setNoData(inNoData);
if (metadataKeyValue != null && !metadataKeyValue.isEmpty()) {
metadata.setTiffTagsMetadata(metadataKeyValue);
}
//
// write image
// writing ALWAYS the geophysics vew of the data