Visualize negative/positive data using levelplot in R

假如想象 提交于 2019-12-20 05:05:06

问题


I need your insights on how to visualize/map data that span negative and positive values. I have 6 rasters which have been stacked together (s) and will subsequently be plotted via the levelplot function in R. Below are the max and min values for each raster.

39.2887, 53.09207  (min, max) # r1
-32.4956, -27.25534  (min, max)# r2   
-14.37683, -11.37742  (min, max)# r3    
9.512934, 13.60197  (min, max)# r4    
-4.993901, -1.851784  (min, max)# r5    
-8.190711, -5.104764  (min, max)# r6

At the moment, I am able to produce my map via:

library(raster)
library(rasterVis)
library(colorRamp)
    s <- stack(r1,r2,r3,r4,r5,r6)
    themes2 <- colorRampPalette(c("darkred", "red3", "orange", "yellow", "lightskyblue", "royalblue3", "darkblue"))(19)
    myat =unique(seq(floor(min(s)) ,ceiling(max(s)),length.out=20))
    myat=round(myat,digits = 0)#     
    #themes <- rasterTheme(region=rev(brewer.pal(11,'RdYlBu')))
    myColorkey <- list(at=myat,space = "right",labels=list(cex=1,at=myat))

    if (dev.cur() == 1) x11(width=18,height=18)

    levelplot(s, layout=c(3, 2), index.cond=list(c(1, 3, 5, 2, 4, 6)),col.regions=themes2,  
              margin=FALSE,xlab=NULL,at =unique(seq(floor(min(s)) ,ceiling(max(s)),length.out=20)),
              par.strip.text=list(cex=0),colorkey=myColorkey,scales=list(alternating=F))

NOTE: I need a single colorkey common to all rasters.

Problem: for rasters with smaller ranges, the variation amongst cells is poorly conveyed - the information on the map is not well visualized. How can I visualize such data using levelplot with this large overall range?

You can generate 6 rasters with values within the ranges shown above to give me further clues.

Thanks for your help! The colorkey does not need to be red to blue. Something like "The Default Rainbow Palette" would do.

"

I need a single, shared colorkey for all of these rasters. At the moment, rasters with smaller cell ranges show very LITTLE variation.


回答1:


In my opinion, you have two choices:

  1. Use a different key for each graph.
  2. Rescale the data to create a common scale.

Because you need a single colorkey you should rescale the data. Although this document is about time series, it gives good advices about this issue.



来源:https://stackoverflow.com/questions/28753126/visualize-negative-positive-data-using-levelplot-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!