public static void writeGridCoverageFromGrassraster( File mapFile, JGrassRegion writeRegion, GridCoverage2D grassCoverage )
throws Exception {
JGrassMapEnvironment mapEnvironment = new JGrassMapEnvironment(mapFile);
GrassCoverageFormat format = new GrassCoverageFormatFactory().createFormat();
GridCoverageWriter writer = format.getWriter(mapEnvironment.getCELL(), null);
GeneralParameterValue[] readParams = null;
if (writeRegion == null) {
writeRegion = mapEnvironment.getActiveRegion();
}
readParams = JGrassCatalogUtilities.createGridGeometryGeneralParameter(writeRegion.getCols(), writeRegion.getRows(),
writeRegion.getNorth(), writeRegion.getSouth(), writeRegion.getEast(), writeRegion.getWest(),
mapEnvironment.getCoordinateReferenceSystem());
writer.write(grassCoverage, readParams);
}