使用R中的levelplot可视化负/正数据 [英] Visualize negative/positive data using levelplot in R

查看:225
本文介绍了使用R中的levelplot可视化负/正数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要您对如何可视化/映射跨越负值和正值的数据的见解.我有6个栅格已堆叠在一起(s),随后将通过R中的levelplot函数进行绘制.以下是每个rastermaxmin值.

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.

问题:对于范围较小的栅格,像元之间的变化难以传达-地图上的信息无法很好地可视化.如何使用levelplot在如此大的范围内可视化此类数据?

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?

您可以生成6个栅格,其值在上面显示的范围内,以给我进一步的线索.

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.

推荐答案

在我看来,您有两种选择:

In my opinion, you have two choices:

  1. 为每个图形使用不同的键.
  2. 重新缩放数据以创建通用比例.

由于只需要一个色键,因此应重新缩放数据.尽管本文档是关于时间序列的,但它对这个问题给出了很好的建议

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.

这篇关于使用R中的levelplot可视化负/正数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆