public class GeotiffWriter
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected int[] |
colorTable |
protected GeoTiff |
geotiff |
protected short |
pageNumber |
Constructor and Description |
---|
GeotiffWriter(java.lang.String fileOut)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static java.util.HashMap<java.lang.Integer,java.awt.Color> |
createColorMap(int[] flag_values,
java.lang.String[] flag_colors)
Creates a colormap in the form of a mapping of the pixel value to the rgb color.
|
int[] |
getColorTable()
Get a copy of the current colormap as a 1-D 3*256 element array (or null).
|
void |
setColorTable(java.util.Map<java.lang.Integer,java.awt.Color> colorMap)
Have the geotiff include a colormap in the form of a mapping of the pixel value to the rgb triplet.
|
void |
setColorTable(java.util.Map<java.lang.Integer,java.awt.Color> colorMap,
java.awt.Color defaultRGB)
Have the geotiff include a colormap in the form of a mapping of the pixel value to the rgb triplet.
|
void |
writeGrid(GeoReferencedArray array,
boolean greyScale)
Write GridCoverage data to the geotiff file.
|
void |
writeGrid(GeoReferencedArray array,
boolean greyScale,
DataType dtype)
Write GridCoverage data to the geotiff file.
|
void |
writeGrid(GridDataset dataset,
GridDatatype grid,
Array data,
boolean greyScale)
Write GridDatatype data to the geotiff file.
|
void |
writeGrid(GridDataset dataset,
GridDatatype grid,
Array data,
boolean greyScale,
DataType dtype)
Write GridDatatype data to the geotiff file.
|
protected GeoTiff geotiff
protected short pageNumber
protected int[] colorTable
public GeotiffWriter(java.lang.String fileOut)
fileOut
- name of output file.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public void writeGrid(GridDataset dataset, GridDatatype grid, Array data, boolean greyScale) throws java.io.IOException
dataset
- grid in contained in this datasetgrid
- data is in this griddata
- 2D array in YX ordergreyScale
- if true, write greyScale image, else dataSample.java.io.IOException
- on i/o errorpublic void writeGrid(GridDataset dataset, GridDatatype grid, Array data, boolean greyScale, DataType dtype) throws java.io.IOException, java.lang.IllegalArgumentException
dataset
- grid in contained in this datasetgrid
- data is in this griddata
- 2D array in YX ordergreyScale
- if true, write greyScale image, else dataSample.dtype
- DataType for the output. See other writeGrid() documentation for more details.java.io.IOException
- on i/o errorjava.lang.IllegalArgumentException
- if above assumptions not validpublic int[] getColorTable()
public void setColorTable(java.util.Map<java.lang.Integer,java.awt.Color> colorMap)
public void setColorTable(java.util.Map<java.lang.Integer,java.awt.Color> colorMap, java.awt.Color defaultRGB)
public static java.util.HashMap<java.lang.Integer,java.awt.Color> createColorMap(int[] flag_values, java.lang.String[] flag_colors) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException
flag_values
- is an array of values for each categoricalflag_colors
- is an array of octal strings (e.g., #00AAFF) of same length as flag_values.java.lang.IllegalArgumentException
- if above assumptions not validjava.lang.NumberFormatException
- if a supplied color isn't parsablepublic void writeGrid(GeoReferencedArray array, boolean greyScale) throws java.io.IOException
array
- GeoReferencedArray array in YX ordergreyScale
- if true, write greyScale image, else dataSample.java.io.IOException
- on i/o errorpublic void writeGrid(GeoReferencedArray array, boolean greyScale, DataType dtype) throws java.io.IOException, java.lang.IllegalArgumentException
array
- GeoReferencedArray array in YX ordergreyScale
- if true, write greyScale image, else dataSample.dtype
- if greyScale is false, then save the data in the given data type.
Currently, this is a bit hobbled in order to avoid back-compatibility breaks.
If greyScale is true and this is not UBYTE, then an exception is thrown.
If dtype is DOUBLE, it downcasted to FLOAT instead.
If using the colorTable and this is not UBYTE, then an exception is thrown.
If null, then use the datatype of the given array.java.io.IOException
- on i/o errorjava.lang.IllegalArgumentException
- if data isn't regular or if contradicting the greyScale argument.