[R-sig-Geo] Visualize negative/poitive data using levelplot in R

Oscar Perpiñan oscar.perpinan at gmail.com
Sat Feb 28 08:17:05 CET 2015


Hello,

You did answer this same question at stackoverflow (
http://stackoverflow.com/q/28753126/964866) without letting us know about
it. This post is worth reading if you really need to do cross-posting (
http://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites
):


This practice may not be in the interests of the ranchers who might be
responding to your posts. Many folks may find that they have wasted their
time and effort. You certainly don't want to annoy those you want to help
you, so you might want to make the experience as painless as possible.
The best way to do something like this (without ticking people off) would
be to let people know upfront that the crossposting is occurring. This
makes the most sense if there's a respectable delay between posting in one
forum and another, e.g:
"I posted this question the other day in SomeOtherForum.com [link], but
wasn't able to get a good answer, so now I'm asking here..."


I have just posted a simple answer to your question which I reproduce here:

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 (
http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf)
is about time series, it gives good advices about this issue.

Best,

Oscar.

-----------------------------------------------------------------
Oscar Perpiñán Lamigueiro
Dpto. Ing. Eléctrica, Electrónica, Automática y Física Aplicada (ETSIDI-UPM)
Grupo de Sistemas Fotovoltaicos (IES-UPM)
URL: http://oscarperpinan.github.io

2015-02-26 22:43 GMT+01:00 Zilefac Elvis via R-sig-Geo <
r-sig-geo at r-project.org>:

> Hello,
> I need your insigts on how to visualize/map data that spans negative and
> positive values. I have 6 rasters which have been stacked together (s) and
> will subsequently be plotted via levelplotfunction 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)# r6At 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 colorkeyProblem: rasters with smaller vs larger values get
> suppressed and the information on the map is not well visualized. How can I
> visualize such data using levelplot with this large range?You can generate
> 6 rasters with values within the ranges shown above to give me further
> clues.Thanks for your help! The colorkey must not be red to blue. Something
> likehttp://iges.org/grads/gadoc/colorcontrol.html "The Default Rainbow
> Palette" would do.
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list