Hi Is there any way to colour a raster by values in a raster attribute table that do not correspond 1:1 with the levels() /ID value in the raster attribute table. The example in the rasterVis documentation https://oscarperpinan.github.io/rastervis/#factor has the categories aligned with the levels. Here is what I would like to achieve r<-raster(matrix(sample(1:9,100,replace=T),10,10)) plot(r) levels(r) r<-ratify(r) df<-data.frame(ID=1:9, Grouping1=sample(LETTERS[1:3],9,replace=T), NewValue = rnorm(9), Grouping2 = sample(LETTERS[4:8],9,replace=T)) rat<-merge(levels(r)[[1]],df) print(rat) levels(r)<-rat plot(r) rasterVis::levelplot(r,att="Grouping1") rasterVis::levelplot(r,att="Grouping2") rasterVis::levelplot(r,att="NewValue") # in all three cases the colouring of the raster remains the same ( according to the levels() or ID). # and the legend only adds a label to each of those levels #I would like to be able to colour the raster according to the unique values in the "groupings" and the legend to have one row for each unique value - eg Grouping 1 legend would have 3 colours corresponding to A B C or on a colour scale for the numeric "NewValue", without reclassifying the raster.
Plotting Raster using values from RAT
1 message · Nevil Amos