Class GeotiffWriter

    • Field Detail

      • geotiff

        protected GeoTiff geotiff
      • pageNumber

        protected short pageNumber
      • colorTable

        protected int[] colorTable
    • Constructor Detail

      • GeotiffWriter

        public GeotiffWriter​(String fileOut)
        Constructor
        Parameters:
        fileOut - name of output file.
    • Method Detail

      • writeGrid

        public void writeGrid​(GridDataset dataset,
                              GridDatatype grid,
                              Array data,
                              boolean greyScale)
                       throws IOException
        Write GridDatatype data to the geotiff file. Greyscale mode will auto-normalize the data from 1 to 255 and save as unsigned bytes, with 0's used for missing data. A color table can be applied if specified via `setColorTable()`. Non-greyscale mode will save the data as floats, encoding missing data as the data minimum minus one.
        Parameters:
        dataset - grid in contained in this dataset
        grid - data is in this grid
        data - 2D array in YX order
        greyScale - if true, write greyScale image, else dataSample.
        Throws:
        IOException - on i/o error
      • writeGrid

        public void writeGrid​(GridDataset dataset,
                              GridDatatype grid,
                              Array data,
                              boolean greyScale,
                              DataType dtype)
                       throws IOException,
                              IllegalArgumentException
        Write GridDatatype data to the geotiff file. Greyscale mode will auto-normalize the data from 1 to 255 and save as unsigned bytes, with 0's used for missing data. Non-greyscale mode with a floating point dtype will save the data as floats, encoding missing data as the data's minimum minus one. Any other dtype will save the data coerced to the specified dtype. A color table can be applied if specified via `setColorTable()` and the dtype is UBYTE.
        Parameters:
        dataset - grid in contained in this dataset
        grid - data is in this grid
        data - 2D array in YX order
        greyScale - if true, write greyScale image, else dataSample.
        dtype - DataType for the output. See other writeGrid() documentation for more details.
        Throws:
        IOException - on i/o error
        IllegalArgumentException - if above assumptions not valid
      • getColorTable

        public int[] getColorTable()
        Get a copy of the current colormap as a 1-D 3*256 element array (or null). All 256 red values first, then green, then blue. For these RGB triplets, 0 is minimum intensity, 65535 is maximum intensity (due to geotiff conventions). This function is intended for debugging and testing.
      • setColorTable

        public void setColorTable​(Map<Integer,​Color> colorMap)
        Have the geotiff include a colormap in the form of a mapping of the pixel value to the rgb triplet. Assumes an RGB of {0, 0, 0} for any values not specified. Pass null to unset the colorTable. For these RGB triplets, 0 is minimum intensity, 255 is maximum intensity. Values outside that range will be floored/ceilinged to the [0, 255] range. The color table is also assumed to be for pixel values between 0 and 255. In order for the color table to be properly included in the geotiff, the output data type must be unsigned bytes. This works even for greyscale mode.
      • setColorTable

        public void setColorTable​(Map<Integer,​Color> colorMap,
                                  Color defaultRGB)
        Have the geotiff include a colormap in the form of a mapping of the pixel value to the rgb triplet. Provide a default RGB triplet for any values not specified. Pass null to unset the colorTable. For these RGB triplets, 0 is minimum intensity, 255 is maximum intensity. Values outside that range will be floored/ceilinged to the [0, 255] range. The color table is also assumed to be for pixel values between 0 and 255. In order for the color table to be properly included in the geotiff, the output data type must be unsigned bytes. This works even for greyscale mode.
      • createColorMap

        public static HashMap<Integer,​Color> createColorMap​(int[] flag_values,
                                                                  String[] flag_colors)
                                                           throws IllegalArgumentException,
                                                                  NumberFormatException
        Creates a colormap in the form of a mapping of the pixel value to the rgb color.
        Parameters:
        flag_values - is an array of values for each categorical
        flag_colors - is an array of octal strings (e.g., #00AAFF) of same length as flag_values.
        Returns:
        Map of the flag values to Color objects the RGB color values, with 0 representing minimum intensity and 255 representing maximum intensity.
        Throws:
        IllegalArgumentException - if above assumptions not valid
        NumberFormatException - if a supplied color isn't parsable
      • writeGrid

        public void writeGrid​(GeoReferencedArray array,
                              boolean greyScale)
                       throws IOException
        Write GridCoverage data to the geotiff file. Greyscale mode will auto-normalize the data from 1 to 255 and save as unsigned bytes, with 0's used for missing data. A color table can be applied if specified via `setColorTable()`. Non-greyscale mode will save the data as floats, encoding missing data as the data minimum minus one.
        Parameters:
        array - GeoReferencedArray array in YX order
        greyScale - if true, write greyScale image, else dataSample.
        Throws:
        IOException - on i/o error
      • writeGrid

        public void writeGrid​(GeoReferencedArray array,
                              boolean greyScale,
                              DataType dtype)
                       throws IOException,
                              IllegalArgumentException
        Write GridCoverage data to the geotiff file. Greyscale mode will auto-normalize the data from 1 to 255 and save as unsigned bytes, with 0's used for missing data. Non-greyscale mode with a floating point dtype will save the data as floats, encoding missing data as the data's minimum minus one. Any other dtype will save the data coerced to the specified dtype. A color table can be applied if specified via `setColorTable()` and the dtype is UBYTE.
        Parameters:
        array - GeoReferencedArray array in YX order
        greyScale - 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.
        Throws:
        IOException - on i/o error
        IllegalArgumentException - if data isn't regular or if contradicting the greyScale argument.