SGDF2RGB {rgdal} | R Documentation |
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.
SGDF2RGB(x, ncolors = 256)
x |
a three-band SpatialGridDataFrame object |
ncolors |
a number of colours between 2 and 256 |
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.
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 |
Roger Bivand
http://www.remotesensing.org/gdal/
## 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)