cdm/src/main/java/ucar/nc2/geotiff/GeotiffWriter.java
protected void writeGrid(GridDatatype grid, Array data, boolean greyScale, double xStart, double yStart, double xInc,
                        double yInc, int imageNumber) throws IOException {

    int nextStart = 0;
    GridCoordSystem gcs = grid.getCoordinateSystem();

    // get rid of this when all projections are implemented
    if (!gcs.isLatLon()
            && !(gcs.getProjection() instanceof LambertConformal)
            && !(gcs.getProjection() instanceof Stereographic)
            && !(gcs.getProjection() instanceof Mercator)
            //  && !(gcs.getProjection() instanceof TransverseMercator)   LOOK broken ??
            && !(gcs.getProjection() instanceof AlbersEqualAreaEllipse)
            && !(gcs.getProjection() instanceof AlbersEqualArea)) {
      throw new IllegalArgumentException("Unsupported projection = " + gcs.getProjection().getClass().getName());
    }

    // write the data first
    MAMath.MinMax dataMinMax = grid.getMinMaxSkipMissingData(data);
    if (greyScale) {
      ArrayByte result = replaceMissingValuesAndScale(grid, data, dataMinMax);
      nextStart = geotiff.writeData((byte[]) result.getStorage(), imageNumber);
    } else {
      ArrayFloat result = replaceMissingValues(grid, data, dataMinMax);
      nextStart = geotiff.writeData((float[]) result.getStorage(), imageNumber);
    }

    // set the width and the height
    int height = data.getShape()[0];         // Y
    int width = data.getShape()[1];         // X

    writeMetadata(greyScale, xStart, yStart, xInc, yInc, height, width, imageNumber, nextStart, dataMinMax, gcs.getProjection());
  }
protected void writeGrid(GridDatatype grid, Array data, boolean greyScale, double xStart, double yStart, double xInc,
                        double yInc, int imageNumber) throws IOException {

    int nextStart = 0;
    GridCoordSystem gcs = grid.getCoordinateSystem();

    // get rid of this when all projections are implemented
    if (!gcs.isLatLon()
            && !(gcs.getProjection() instanceof LambertConformal)
            && !(gcs.getProjection() instanceof Stereographic)
            && !(gcs.getProjection() instanceof Mercator)
            //  && !(gcs.getProjection() instanceof TransverseMercator)   LOOK broken ??
            && !(gcs.getProjection() instanceof AlbersEqualAreaEllipse)
            && !(gcs.getProjection() instanceof AlbersEqualArea)) {
      throw new IllegalArgumentException("Unsupported projection = " + gcs.getProjection().getClass().getName());
    }

    // write the data first
    MAMath.MinMax dataMinMax = grid.getMinMaxSkipMissingData(data);
    if (greyScale) {
      ArrayByte result = replaceMissingValuesAndScale(grid, data, dataMinMax);
      nextStart = geotiff.writeData((byte[]) result.getStorage(), imageNumber);
    } else {
      ArrayFloat result = replaceMissingValues(grid, data, dataMinMax);
      nextStart = geotiff.writeData((float[]) result.getStorage(), imageNumber);
    }

    // set the width and the height
    int height = data.getShape()[0];         // Y
    int width = data.getShape()[1];         // X

    writeMetadata(greyScale, xStart, yStart, xInc, yInc, height, width, imageNumber, nextStart, dataMinMax, gcs.getProjection());
  }
protected void writeGrid ( GridDatatype grid , Array data , boolean greyScale , double xStart , double yStart , double xInc , double yInc , int imageNumber ) throws IOException { int nextStart = 0 ; GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; // get rid of this when all projections are implemented if ( ! gcs . isLatLon ( ) && ! ( gcs . getProjection ( ) instanceof LambertConformal ) && ! ( gcs . getProjection ( ) instanceof Stereographic ) && ! ( gcs . getProjection ( ) instanceof Mercator ) //  && !(gcs.getProjection() instanceof TransverseMercator)   LOOK broken ?? && ! ( gcs . getProjection ( ) instanceof AlbersEqualAreaEllipse ) && ! ( gcs . getProjection ( ) instanceof AlbersEqualArea ) ) { throw new IllegalArgumentException ( "Unsupported projection = " + gcs . getProjection ( ) . getClass ( ) . getName ( ) ) ; } // write the data first MAMath . MinMax dataMinMax = grid . getMinMaxSkipMissingData ( data ) ; if ( greyScale ) { ArrayByte result = replaceMissingValuesAndScale ( grid , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( byte [ ] ) result . getStorage ( ) , imageNumber ) ; } else { ArrayFloat result = replaceMissingValues ( grid , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( float [ ] ) result . getStorage ( ) , imageNumber ) ; } // set the width and the height int height = data . getShape ( ) [ 0 ] ; // Y int width = data . getShape ( ) [ 1 ] ; // X writeMetadata ( greyScale , xStart , yStart , xInc , yInc , height , width , imageNumber , nextStart , dataMinMax , gcs . getProjection ( ) ) ; }
Write Grid data to the geotiff file.
Grid currently must:
<ol>
<li> have a 1D X and Y coordinate axes.
<li> be lat/lon or Lambert Conformal Projection
<li> be equally spaced
</ol>

@param grid        original grid
@param data        2D array in YX order
@param greyScale   if true, write greyScale image, else dataSample.
@param xStart
@param yStart
@param xInc
@param yInc
@param imageNumber
@throws IOException              on i/o error
@throws IllegalArgumentException if above assumptions not valid
Write Grid data to the geotiff file . Grid currently must : <ol > <li > have a 1D X and Y coordinate axes . <li > be lat / lon or Lambert Conformal Projection <li > be equally spaced < / ol >