public void writeGrid ( GridDataset dataset , GridDatatype grid , Array data , boolean greyScale ) throws IOException { GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; if ( ! gcs . isRegularSpatial ( ) ) { throw new IllegalArgumentException ( "Must have 1D x and y axes for " + grid . getFullName ( ) ) ; } CoordinateAxis1D xaxis = ( CoordinateAxis1D ) gcs . getXHorizAxis ( ) ; CoordinateAxis1D yaxis = ( CoordinateAxis1D ) gcs . getYHorizAxis ( ) ; // units may need to be scaled to meters double scaler = ( xaxis . getUnitsString ( ) . equalsIgnoreCase ( "km" ) ) ? 1000.0 : 1.0 ; // data must go from top to bottom double xStart = xaxis . getCoordEdge ( 0 ) * scaler ; double yStart = yaxis . getCoordEdge ( 0 ) * scaler ; double xInc = xaxis . getIncrement ( ) * scaler ; double yInc = Math . abs ( yaxis . getIncrement ( ) ) * scaler ; if ( yaxis . getCoordValue ( 0 ) < yaxis . getCoordValue ( 1 ) ) { data = data . flip ( 0 ) ; yStart = yaxis . getCoordEdge ( ( int ) yaxis . getSize ( ) ) * scaler ; } if ( ! xaxis . isRegular ( ) || ! yaxis . isRegular ( ) ) { throw new IllegalArgumentException ( "Must be evenly spaced grid = " + grid . getFullName ( ) ) ; } if ( pageNumber > 1 ) { geotiff . initTags ( ) ; } // write it out writeGrid ( grid , data , greyScale , xStart , yStart , xInc , yInc , pageNumber ) ; pageNumber ++ ; }
Write GridDatatype data to the geotiff file .