Does anyone know how to import a legend for a raster layer (loaded as a .tif) into R such that it can be attached to the raster file itself and used in plotting?
In this case, I am using the GLC2009 V2.3 data, available from: http://due.esrin.esa.int/page_globcover.php
The legend is stored separately as a .xls file, as well as .lyr and .dsr files. I believe the latter 2 extensions are for ArcINFO files but regardless I have never used either in R.
I can import the .xls legend as follows easily:
GLC_Legend <- read.xlsx("./Globcover2009_V2.3/Globcover2009_Legend.xls", sheetIndex=1, header=TRUE) head(GLC_Legend) # Value Label Red Green Blue # 1 11 Post-flooding or irrigated croplands (or aquatic) 170 240 240 # 2 14 Rainfed croplands 255 255 100
But I am lost as to how I could utilize this data frame to re-create the color map, as well as to how I could use the .lyr or .dsr files in its stead. Any know-how on importing colormaps from files for mapping purposes in R would be wonderful!