SGDF2RGB {rgdal}R Documentation

Convert RGB three band to single band colour table

Description

This function converts a three-band SpatialGridDataFrame into a single band of colour indices and a colour look-up table. The function is in preliminary form only.

Usage

SGDF2RGB(x, ncolors = 256)

Arguments

x a three-band SpatialGridDataFrame object
ncolors a number of colours between 2 and 256

Details

The function makes a system() call to the GDAL utility rgb2pct.py, which is only available if GDAL has been built with Python support. It is hoped to replace this extra dependency with compiled code if the function proves useful.

Value

The value returned is a list:

idx a vector of colour indices in the same spatial order as the input object
ct a vector of RGB colours

Author(s)

Roger Bivand

References

http://www.remotesensing.org/gdal/

Examples

## Not run: 
  logo <- system.file("pictures/Rlogo.jpg", package="rgdal")[1]
  SGlogo <- readGDAL(logo)
  cols <- SGDF2RGB(SGlogo)
  SGlogo$idx <- cols$idx
  image(SGlogo, "idx", col=cols$ct)
  SGlogo <- readGDAL(logo)
  cols <- SGDF2RGB(SGlogo, ncolors=64)
  SGlogo$idx <- cols$idx
  image(SGlogo, "idx", col=cols$ct)
## End(Not run)

[Package rgdal version 0.4-12 Index]