code: public static WritableRaster createWritableRasterFromMatrix( double[][] matrix, boolean matrixIsRowCol ) {
          int height = matrix.length;
          int width = matrix[0].length;
          if (!matrixIsRowCol) {
              int tmp = height;
              height = width;
              width = tmp;
          }
          WritableRaster writableRaster = createWritableRaster(width, height, null, null, HMConstants.doubleNovalue);
  
          WritableRandomIter rasterIter = RandomIterFactory.createWritable(writableRaster, null);
          for( int x = 0; x < width; x++ ) {
              for( int y = 0; y < height; y++ ) {
                  if (matrixIsRowCol) {
                      if (!HMConstants.isNovalue(matrix[y][x]))
                          rasterIter.setSample(x, y, 0, matrix[y][x]);
                  } else {
                      if (!HMConstants.isNovalue(matrix[x][y]))
                          rasterIter.setSample(x, y, 0, matrix[x][y]);
                  }
              }
          }
          rasterIter.done();
  
          return writableRaster;
      }
docs: Create a {@link WritableRaster} from a double matrix.
  
  @param matrix the matrix to take the data from.
  @param matrixIsRowCol a flag to tell if the matrix has rowCol or colRow order.
  @return the produced raster.