Skip to content
Prev 2514 / 29559 Next

Image colours based on certain values

Dear R Spatial Users,

I have many DEM ASCII grid files and have produced maps(images) via 
image(). The maps display e.g. slope angle, profile curvature for one area, 
but calculated via different methods.

I have searched R help, the R group, but I couldn't find out how to make R 
use certain colours for certain image values, in order to be able to 
compare the maps, for instance to have the same color for 0 curvature 
values, no matter what is the range of values.

If it helps, the following is applied in a 'for' loop for 20 files: 

raster.values <- read.asciigrid(fname=Files[i], as.image = FALSE,  
                          plot.image = FALSE, colname = Files[i])

min.val <- min(raster.values at data, na.rm=TRUE)
max.val <- max(raster.values at data, na.rm=TRUE)
 
image(raster.values, zlim=c(min.val,max.val), col=bpy.colors(255, 
cutoff.tails = 0.1), axes=TRUE)

I appreciate and thank you for help.

Michal