colortable

This module contains routines for dealing with large color tables. This module uses the Raster Attribute Table functions which are the fastest method to access the color table that GDAL provides.

The more general rios.rat and rios.ratapplier modules can be used for reading and writing generic Raster Attribute Table Columns.

The getRampNames() and genTable() functions access the built in color ramps (mainly derived from https://colorbrewer2.org/ - see this website for more information about the ramps and when to use them).

The setTable()/getTable() functions write and read color tables to file formats that support accessing color tables with the Raster Attribute Table functions.

exception rios.colortable.ColorTableException[source]

Exception for errors related to color table access

exception rios.colortable.ColorTableMissingException[source]

Exception for errors related to errors reading color table

rios.colortable.addRamp(name, red, green, blue)[source]

Add a new ramp to the internal list of color ramps so that it can be used with genTable() etc.

red, green and blue must be strings with the values, space separated. These values should be 0-255 and have the same number of values for each color.

rios.colortable.genTable(numEntries, colorType, ignoreVal=None, colorPoints=None)[source]

Generate the named color table for use with setTable().

colorType should be one of the names returned from getRampNames().

numEntries is the size of the table that is generated and should correspond to the range of data you have in the output file.

If ignoreVal is specified then the opacity for this row is set to 0 - ie totally transparent. Use this for preparing images for display so images underneath in a viewer show through where the ignoreVal is set.

If colorPoints is set it should be a sequence of entry numbers to use for the points on the color ramp. If not given the points on the color ramp are evenly spread 0-numEntries. Actual colors for points between are interpolated.

The returned colour table is a numpy array, described in detail in the docstring for colortable.setTable().

rios.colortable.getRampNames()[source]

Get a list of names of the available color ramps

rios.colortable.getTable(imgFile, bandNumber=1)[source]

Given either an open gdal dataset, or a filename, reads the color table as an array that can be passed to setColorTable().

The returned colour table is a numpy array, described in detail in the docstring for colortable.setTable().

If there is no color table, returns None.

rios.colortable.loadBuiltinRamps()[source]

This function simply loads the built in color ramps into a dictionary. From http://colorbrewer.org/ and Python code generated by TuiView’s colorbrewer2py.py.

rios.colortable.setTable(imgFile, colorTable, bandNumber=1)[source]

Given either an open gdal dataset, or a filename, sets the color table as an array.

The colorTable is given as an array of shape (4, numEntries) where numEntries is the size of the color table. The order of indices in the first axis is:

  • Red
  • Green
  • Blue
  • Opacity

The Red/Green/Blue values are on the range 0-255, with 255 meaning full color, and the opacity is in the range 0-255, with 255 meaning fully opaque.

This table is useually generated by getTable() or genTable().