code: public static GridCoverage2D buildCoverage( String name, WritableRaster writableRaster,
              HashMap<String, Double> envelopeParams, CoordinateReferenceSystem crs ) {
          if (writableRaster instanceof GrassLegacyWritableRaster) {
              GrassLegacyWritableRaster wRaster = (GrassLegacyWritableRaster) writableRaster;
              double west = envelopeParams.get(WEST);
              double south = envelopeParams.get(SOUTH);
              double east = envelopeParams.get(EAST);
              double north = envelopeParams.get(NORTH);
              int rows = envelopeParams.get(ROWS).intValue();
              int cols = envelopeParams.get(COLS).intValue();
              Window window = new Window(west, east, south, north, rows, cols);
              GrassLegacyGridCoverage2D coverage2D = new GrassLegacyGridCoverage2D(window, wRaster.getData(), crs);
              return coverage2D;
          } else {
              double west = envelopeParams.get(WEST);
              double south = envelopeParams.get(SOUTH);
              double east = envelopeParams.get(EAST);
              double north = envelopeParams.get(NORTH);
              Envelope2D writeEnvelope = new Envelope2D(crs, west, south, east - west, north - south);
              GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
  
              GridCoverage2D coverage2D = factory.create(name, writableRaster, writeEnvelope);
              return coverage2D;
          }
      }
docs: Creates a {@link GridCoverage2D coverage} from the {@link WritableRaster writable raster} and the necessary geographic Information.
  
  @param name the name of the coverage.
  @param writableRaster the raster containing the data.
  @param envelopeParams the map of boundary parameters.
  @param crs the {@link CoordinateReferenceSystem}.
  @return the {@link GridCoverage2D coverage}.