|
GDAL
|
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute information about pixel values. More...
Public Member Functions | |
| virtual GDALRasterAttributeTable * | Clone () const =0 |
| Copy Raster Attribute Table. | |
| virtual int | GetColumnCount () const =0 |
| Fetch table column count. | |
| virtual const char * | GetNameOfCol (int iCol) const =0 |
| Fetch name of indicated column. | |
| virtual GDALRATFieldUsage | GetUsageOfCol (int iCol) const =0 |
| Fetch column usage value. | |
| virtual GDALRATFieldType | GetTypeOfCol (int iCol) const =0 |
| Fetch column type. | |
| virtual int | GetColOfUsage (GDALRATFieldUsage eUsage) const =0 |
| Fetch column index for given usage. | |
| virtual int | GetRowCount () const =0 |
| Fetch row count. | |
| virtual const char * | GetValueAsString (int iRow, int iField) const =0 |
| Fetch field value as a string. | |
| virtual int | GetValueAsInt (int iRow, int iField) const =0 |
| Fetch field value as a integer. | |
| virtual double | GetValueAsDouble (int iRow, int iField) const =0 |
| Fetch field value as a double. | |
| virtual bool | GetValueAsBoolean (int iRow, int iField) const =0 |
| Fetch field value as a boolean. | |
| virtual GDALRATDateTime | GetValueAsDateTime (int iRow, int iField) const =0 |
| Fetch field value as a datetime. | |
| virtual const GByte * | GetValueAsWKBGeometry (int iRow, int iField, size_t &nWKBSize) const =0 |
| Fetch field value as a WKB geometry. | |
| virtual CPLErr | SetValue (int iRow, int iField, const char *pszValue)=0 |
| Set field value from string. | |
| virtual CPLErr | SetValue (int iRow, int iField, int nValue)=0 |
| Set field value from integer. | |
| virtual CPLErr | SetValue (int iRow, int iField, double dfValue)=0 |
| Set field value from double. | |
| virtual CPLErr | SetValue (int iRow, int iField, bool bValue)=0 |
| Set field value from boolean. | |
| virtual CPLErr | SetValue (int iRow, int iField, const GDALRATDateTime &sDateTime)=0 |
| Set field value from datetime. | |
| virtual CPLErr | SetValue (int iRow, int iField, const void *pabyWKB, size_t nWKBSize)=0 |
| Set field value from a WKB geometry. | |
| virtual int | ChangesAreWrittenToFile ()=0 |
| Determine whether changes made to this RAT are reflected directly in the dataset. | |
| virtual CPLErr | SetTableType (const GDALRATTableType eInTableType)=0 |
| Set the RAT table type. | |
| virtual GDALRATTableType | GetTableType () const =0 |
| Get the RAT table type. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, double *pdfData) |
| Read or Write a block of doubles to/from the Attribute Table. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, int *pnData) |
| Read or Write a block of integers to/from the Attribute Table. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, char **papszStrList) |
| Read or Write a block of strings to/from the Attribute Table. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, bool *pbData) |
| Read or Write a block of booleans to/from the Attribute Table. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, GDALRATDateTime *pasDateTime) |
| Read or Write a block of DateTime to/from the Attribute Table. | |
| virtual CPLErr | ValuesIO (GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, GByte **ppabyWKB, size_t *pnWKBSize) |
| Read or Write a block of WKB-encoded geometries to/from the Attribute Table. | |
| virtual void | SetRowCount (int iCount) |
| Set row count. | |
| virtual int | GetRowOfValue (double dfValue) const |
| Get row for pixel value. | |
| virtual int | GetRowOfValue (int nValue) const |
| Get row for pixel value. | |
| virtual CPLErr | CreateColumn (const char *pszFieldName, GDALRATFieldType eFieldType, GDALRATFieldUsage eFieldUsage) |
| If the table already has rows, all row values for the new column will be initialized to the default value ("", or zero). | |
| virtual CPLErr | SetLinearBinning (double dfRow0Min, double dfBinSize) |
| Set linear binning information. | |
| virtual int | GetLinearBinning (double *pdfRow0Min, double *pdfBinSize) const |
| Get linear binning information. | |
| virtual CPLXMLNode * | Serialize () const |
| Serialize. | |
| virtual void * | SerializeJSON () const |
| Serialize as a JSON object. | |
| virtual CPLErr | XMLInit (const CPLXMLNode *, const char *) |
| Deserialize from XML. | |
| virtual CPLErr | InitializeFromColorTable (const GDALColorTable *) |
| Initialize from color table. | |
| virtual GDALColorTable * | TranslateToColorTable (int nEntryCount=-1) |
| Translate to a color table. | |
| virtual void | DumpReadable (FILE *=nullptr) |
| Dump RAT in readable form. | |
| virtual void | RemoveStatistics ()=0 |
| Remove statistics from the RAT. | |
Static Public Member Functions | |
| static GDALRasterAttributeTableH | ToHandle (GDALRasterAttributeTable *poRAT) |
| Convert a GDALRasterAttributeTable* to a GDALRasterAttributeTableH. | |
| static GDALRasterAttributeTable * | FromHandle (GDALRasterAttributeTableH hRAT) |
| Convert a GDALRasterAttributeTableH to a GDALRasterAttributeTable*. | |
The GDALRasterAttributeTable (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.
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, string, boolean, date time, geometries encoded as WKB), 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 determined 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 GDALRasterBands and can be queried using the GDALRasterBand::GetDefaultRAT() method.
|
pure virtual |
Determine whether changes made to this RAT are reflected directly in the dataset.
If this returns FALSE then GDALRasterBand.SetDefaultRAT() should be called. Otherwise this is unnecessary since changes to this object are reflected in the dataset.
This method is the same as the C function GDALRATChangesAreWrittenToFile().
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Copy Raster Attribute Table.
Creates a new copy of an existing raster attribute table. The new copy becomes the responsibility of the caller to destroy. May fail (return nullptr) if the attribute table is too large to clone (GetRowCount() * GetColCount() > RAT_MAX_ELEM_FOR_CLONE)
This method is the same as the C function GDALRATClone().
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
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, and will be column (field) "GetColumnCount()-1" after CreateColumn() has completed successfully.
This method is the same as the C function GDALRATCreateColumn().
| pszFieldName | the name of the field to create. |
| eFieldType | the field type (integer, double or string). |
| eFieldUsage | the field usage, GFU_Generic if not known. |
Reimplemented in GDALDefaultRasterAttributeTable.
|
virtual |
Dump RAT in readable form.
Currently the readable form is the XML encoding ... only barely readable.
This method is the same as the C function GDALRATDumpReadable().
| fp | file to dump to or NULL for stdout. |
|
pure virtual |
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.
This method is the same as the C function GDALRATGetUsageOfCol().
| eUsage | usage type to search for. |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch table column count.
This method is the same as the C function GDALRATGetColumnCount().
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
Get linear binning information.
Returns linear binning information if any is associated with the RAT.
This method is the same as the C function GDALRATGetLinearBinning().
| pdfRow0Min | (out) the lower bound (pixel value) of the first category. |
| pdfBinSize | (out) the width of each category (in pixel value units). |
Reimplemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch name of indicated column.
This method is the same as the C function GDALRATGetNameOfCol().
| iCol | the column index (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch row count.
This method is the same as the C function GDALRATGetRowCount().
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
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.
This method is the same as the C function GDALRATGetRowOfValue().
| dfValue | the pixel value. |
Reimplemented in GDALDefaultRasterAttributeTable.
|
virtual |
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.
Int arg for now just converted to double. Perhaps we will handle this in a special way some day?
This method is the same as the C function GDALRATGetRowOfValue().
| nValue | the pixel value. |
Reimplemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Get the RAT table type.
Indicates whether the RAT is thematic or athematic (continuous).
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch column type.
This method is the same as the C function GDALRATGetTypeOfCol().
| iCol | the column index (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch column usage value.
This method is the same as the C function GDALRATGetUsageOfCol().
| iCol | the column index (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a boolean.
The value of the requested column in the requested row is returned as a boolean. This method is nominally called on fields of type GFT_Boolean, but it can be called on fields of other types as well. Non boolean fields will be converted to boolean with the possibility of data loss.
This method is the same as the C function GDALRATGetValueAsBoolean().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a datetime.
The value of the requested column in the requested row is returned as a datetime. Besides being called on a GFT_DateTime field, it is also possible to call this method on a string field that contains a ISO-8601 encoded datetime.
This method is the same as the C function GDALRATGetValueAsDateTime().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a double.
The value of the requested column in the requested row is returned as a double. This method is nominally called on fields of type GFT_Real, but it can be called on fields of other types as well. Non double fields will be converted to double with the possibility of data loss.
This method is the same as the C function GDALRATGetValueAsDouble().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a integer.
The value of the requested column in the requested row is returned as an integer. This method is nominally called on fields of type GFT_Integer, but it can be called on fields of other types as well. Non-integer fields will be converted to integer with the possibility of data loss.
This method is the same as the C function GDALRATGetValueAsInt().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a string.
The value of the requested column in the requested row is returned as a string. This method is nominally called on fields of type GFT_String, but it can be called on fields of other types as well. If the field is numeric, it is formatted as a string using default rules, so some precision may be lost.
The returned string is temporary and cannot be expected to be available after the next GDAL call.
This method is the same as the C function GDALRATGetValueAsString().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Fetch field value as a WKB geometry.
The value of the requested column in the requested row is returned as a WKB geometry. Besides being called on a GFT_WKBGeometry field, it is also possible to call this method on a string field that contains a WKT encoded geometry.
The returned pointer may be invalidated by a following call to a method of this GDALRasterAttributeTable instance.
This method is the same as the C function GDALRATGetValueAsWKBGeometry().
| iRow | row to fetch (zero based). | |
| iField | column to fetch (zero based). | |
| [out] | nWKBSize | Number of bytes of the returned pointer |
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
Initialize from color table.
This method will setup a whole raster attribute table based on the contents of the passed color table. The Value (GFU_MinMax), Red (GFU_Red), Green (GFU_Green), Blue (GFU_Blue), and Alpha (GFU_Alpha) fields are created, and a row is set for each entry in the color table.
The raster attribute table must be empty before calling InitializeFromColorTable().
The Value fields are set based on the implicit assumption with color tables that entry 0 applies to pixel value 0, 1 to 1, etc.
This method is the same as the C function GDALRATInitializeFromColorTable().
| poTable | the color table to copy from. |
|
pure virtual |
Remove statistics from the RAT.
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
Serialize.
Serialize as a XML tree.
May fail (return nullptr) if the attribute table is too large to serialize (GetRowCount() * GetColCount() > RAT_MAX_ELEM_FOR_CLONE)
|
virtual |
Serialize as a JSON object.
|
virtual |
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.
This method is the same as the C function GDALRATSetLinearBinning().
| dfRow0MinIn | the lower bound (pixel value) of the first category. |
| dfBinSizeIn | the width of each category (in pixel value units). |
Reimplemented in GDALDefaultRasterAttributeTable.
|
virtual |
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.
This method is the same as the C function GDALRATSetRowCount().
| nNewCount | the new number of rows. |
Reimplemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set the RAT table type.
Set whether the RAT is thematic or athematic (continuous).
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from boolean.
The indicated field (column) on the indicated row is set from the passed value. This method is nominally called on fields of type GFT_Boolean, but it can be called on fields of other types as well. The value will be automatically converted for other field types, with a possible loss of precision.
This method is the same as the C function GDALRATSetValueAsBoolean().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| bValue | the value to assign. |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from string.
The indicated field (column) on the indicated row is set from the passed value. This method is nominally called on fields of type GFT_String, but it can be called on fields of other types as well. The value will be automatically converted for other field types, with a possible loss of precision.
This method is the same as the C function GDALRATSetValueAsString().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| pszValue | the value to assign. |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from datetime.
The indicated field (column) on the indicated row is set from the passed value. Besides being called on a field of type GFT_DateTime, this method can also be called on a field of type GFT_String, in which case the datetime will be converted into its ISO-8601 representation.
Note that the GDALRATDateTime::bIsValid field must be set to true if the date time is valid.
This method is the same as the C function GDALRATSetValueAsDateTime().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| sDateTime | Date time value |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from a WKB geometry.
The indicated field (column) on the indicated row is set from the passed value. Besides being called on a field of type GFT_WKBGeometry, this method can also be called on a field of type GFT_String, in which case the datetime will be converted into its WKT geometry representation.
This method is the same as the C function GDALRATSetValueAsWKBGeometry().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| pabyWKB | Pointer to a WKB encoded geometry |
| nWKBSize | Number of bytes of pabyWKB. |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from double.
The indicated field (column) on the indicated row is set from the passed value. This method is nominally called on fields of type GFT_Real, but it can be called on fields of other types as well. The value will be automatically converted for other field types, with a possible loss of precision.
This method is the same as the C function GDALRATSetValueAsDouble().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| dfValue | the value to assign. |
Implemented in GDALDefaultRasterAttributeTable.
|
pure virtual |
Set field value from integer.
The indicated field (column) on the indicated row is set from the passed value. This method is nominally called on fields of type GFT_Integer, but it can be called on fields of other types as well. The value will be automatically converted for other field types, with a possible loss of precision.
This method is the same as the C function GDALRATSetValueAsInteger().
| iRow | row to fetch (zero based). |
| iField | column to fetch (zero based). |
| nValue | the value to assign. |
Implemented in GDALDefaultRasterAttributeTable.
|
virtual |
Translate to a color table.
This method will attempt to create a corresponding GDALColorTable from this raster attribute table.
This method is the same as the C function GDALRATTranslateToColorTable().
| nEntryCount | The number of entries to produce (0 to nEntryCount-1), or -1 to auto-determine the number of entries. |
|
virtual |
Read or Write a block of booleans to/from the Attribute Table.
This method is the same as the C function GDALRATValuesIOAsBoolean().
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| pbData | pointer to array of booleans to read/write. Should be at least iLength long. |
|
virtual |
Read or Write a block of strings to/from the Attribute Table.
This method is the same as the C function GDALRATValuesIOAsString(). When reading, papszStrList must be already allocated to the correct size. The caller is expected to call CPLFree on each read string.
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| papszStrList | pointer to array of strings to read/write. Should be at least iLength long. |
|
virtual |
Read or Write a block of doubles to/from the Attribute Table.
This method is the same as the C function GDALRATValuesIOAsDouble().
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| pdfData | pointer to array of doubles to read/write. Should be at least iLength long. |
|
virtual |
Read or Write a block of WKB-encoded geometries to/from the Attribute Table.
When reading, each ppabyWKB[] should be CPLFree'd() after use.
This method is the same as the C function GDALRATValuesIOAsWKBGeometry().
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| ppabyWKB | pointer to array of pointer of WKB-encoded geometries to read/write. Should be at least iLength long. |
| pnWKBSize | pointer to array of WKB size. Should be at least iLength long. |
|
virtual |
Read or Write a block of DateTime to/from the Attribute Table.
This method is the same as the C function GDALRATValuesIOAsDateTime().
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| psDateTime | pointer to array of DateTime to read/write. Should be at least iLength long. |
|
virtual |
Read or Write a block of integers to/from the Attribute Table.
This method is the same as the C function GDALRATValuesIOAsInteger().
| eRWFlag | either GF_Read or GF_Write |
| iField | column of the Attribute Table |
| iStartRow | start row to start reading/writing (zero based) |
| iLength | number of rows to read or write |
| pnData | pointer to array of ints to read/write. Should be at least iLength long. |
|
virtual |
Deserialize from XML.
| psTree | XML tree |