Package org.gdal.gdal

Class RasterAttributeTable

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class RasterAttributeTable
    extends java.lang.Object
    implements java.lang.Cloneable
    The RasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute information about pixel values. Each row in the table applies to a range of pixel values (or a single value in some cases), and might have attributes such as the histogram count for that range, the color pixels of that range should be drawn names of classes or any other generic information.

    The RasterAttributeTable class is a binding for the C++ GDALRasterAttributeTable class.

    Raster attribute tables can be used to represent histograms, color tables, and classification information.

    Each column in a raster attribute table has a name, a type (integer, floating point or string), and a GDALRATFieldUsage. The usage distinguishes columns with particular understood purposes (such as color, histogram count, name) and columns that have specific purposes not understood by the library (long label, suitability_for_growing_wheat, etc).

    In the general case each row has a column indicating the minimum pixel values falling into that category, and a column indicating the maximum pixel value. These are indicated with usage values of GFU_Min, and GFU_Max. In other cases where each row is a discrete pixel value, one column of usage GFU_MinMax can be used.

    In other cases all the categories are of equal size and regularly spaced and the categorization information can be determine just by knowing the value at which the categories start, and the size of a category. This is called "Linear Binning" and the information is kept specially on the raster attribute table as a whole.

    RATs are normally associated with Bands and be be queried using the Band.GetDefaultRAT() method.

    • Constructor Detail

      • RasterAttributeTable

        public RasterAttributeTable()
        Construct empty table.
    • Method Detail

      • delete

        public void delete()
      • clone

        public java.lang.Object clone()
      • Clone

        public RasterAttributeTable Clone()
        Copy Raster Attribute Table.

        Creates a new copy of an existing raster attribute table.

        Returns:
        new copy of the RAT.
      • GetColumnCount

        public int GetColumnCount()
        Fetch table column count.
        Returns:
        the number of columns.
      • GetNameOfCol

        public java.lang.String GetNameOfCol​(int iCol)
        Fetch name of indicated column.
        Parameters:
        iCol - the column index (zero based).
        Returns:
        the column name or an empty string for invalid column numbers.
      • GetUsageOfCol

        public int GetUsageOfCol​(int iCol)
        Fetch column usage value.
        Parameters:
        iCol - the column index (zero based).
        Returns:
        the column usage, or GFU_Generic for improper column numbers.
      • GetTypeOfCol

        public int GetTypeOfCol​(int iCol)
        Fetch color type.
        Parameters:
        iCol - the column index (zero based).
        Returns:
        column type or GFT_Integer if the column index is illegal.
      • GetColOfUsage

        public int GetColOfUsage​(int eUsage)
        Fetch column index for given usage.

        Returns the index of the first column of the requested usage type, or -1 if no match is found.

        Parameters:
        eUsage - usage type to search for.
        Returns:
        column index, or -1 on failure.
      • GetRowCount

        public int GetRowCount()
        Fetch row count.
        Returns:
        the number of rows.
      • GetValueAsString

        public java.lang.String GetValueAsString​(int iRow,
                                                 int iCol)
        Fetch field value as a string.

        The value of the requested column in the requested row is returned as a string. If the field is numeric, it is formatted as a string using default rules, so some precision may be lost. except it returns a "const char *" result.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        Returns:
        field value
      • GetValueAsInt

        public int GetValueAsInt​(int iRow,
                                 int iCol)
        Fetch field value as a integer.

        The value of the requested column in the requested row is returned as an integer. Non-integer fields will be converted to integer with the possibility of data loss.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        Returns:
        field value
      • GetValueAsDouble

        public double GetValueAsDouble​(int iRow,
                                       int iCol)
        Fetch field value as a double.

        The value of the requested column in the requested row is returned as a double. Non double fields will be converted to double with the possibility of data loss.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        Returns:
        field value
      • SetValueAsString

        public void SetValueAsString​(int iRow,
                                     int iCol,
                                     java.lang.String pszValue)
        Set field value from string.

        The indicated field (column) on the indicated row is set from the passed value. The value will be automatically converted for other field types, with a possible loss of precision.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        pszValue - the value to assign.
      • SetValueAsInt

        public void SetValueAsInt​(int iRow,
                                  int iCol,
                                  int nValue)
        Set field value from integer.

        The indicated field (column) on the indicated row is set from the passed value. The value will be automatically converted for other field types, with a possible loss of precision.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        nValue - the value to assign.
      • SetValueAsDouble

        public void SetValueAsDouble​(int iRow,
                                     int iCol,
                                     double dfValue)
        Set field value from double.

        The indicated field (column) on the indicated row is set from the passed value. The value will be automatically converted for other field types, with a possible loss of precision.

        Parameters:
        iRow - row to fetch (zero based).
        iCol - column to fetch (zero based).
        dfValue - the value to assign.
      • SetRowCount

        public void SetRowCount​(int nCount)
        Set row count.

        Resizes the table to include the indicated number of rows. Newly created rows will be initialized to their default values - "" for strings, and zero for numeric fields.

        Parameters:
        nCount - the new number of rows.
      • CreateColumn

        public int CreateColumn​(java.lang.String name,
                                int eFieldType,
                                int eFieldUsage)
        Create new column.

        If the table already has rows, all row values for the new column will be initialized to the default value ("", or zero). The new column is always created as the last column, can will be column (field) "GetColumnCount()-1" after CreateColumn() has completed successfully.

        Parameters:
        name - the name of the field to create.
        eFieldType - the field type (integer, double or string).
        eFieldUsage - the field usage, GFU_Generic if not known.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure if something goes wrong.
      • GetLinearBinning

        public boolean GetLinearBinning​(double[] pdfRow0Min,
                                        double[] pdfBinSize)
        Get linear binning information.

        Returns linear binning information if any is associated with the RAT.

        Parameters:
        pdfRow0Min - (out) array of 1 double that will contain the lower bound (pixel value) of the first category.
        pdfBinSize - (out) array of 1 double that will contain the width of each category (in pixel value units).
        Returns:
        true if linear binning information exists or false if there is none.
        Since:
        Java bindings 1.7.0
      • SetLinearBinning

        public int SetLinearBinning​(double dfRow0Min,
                                    double dfBinSize)
        Set linear binning information.

        For RATs with equal sized categories (in pixel value space) that are evenly spaced, this method may be used to associate the linear binning information with the table.

        Parameters:
        dfRow0Min - the lower bound (pixel value) of the first category.
        dfBinSize - the width of each category (in pixel value units).
        Returns:
        CE_None on success or CE_Failure on failure.
        Since:
        Java bindings 1.7.0
      • GetRowOfValue

        public int GetRowOfValue​(double dfValue)
        Get row for pixel value.

        Given a raw pixel value, the raster attribute table is scanned to determine which row in the table applies to the pixel value. The row index is returned.

        Parameters:
        dfValue - the pixel value.
        Returns:
        the row index or -1 if no row is appropriate.
      • ChangesAreWrittenToFile

        public int ChangesAreWrittenToFile()
      • DumpReadable

        public void DumpReadable()
      • SetTableType

        public void SetTableType​(int eTableType)
      • GetTableType

        public int GetTableType()
      • RemoveStatistics

        public void RemoveStatistics()