[R-sig-Geo] Plotting 2 rasters over each other on a map with 2D colour scheme

Robin Lovelace rob00x at gmail.com
Thu Sep 22 15:52:22 CEST 2016

Hi Vasya

To some extent this is more a visualisation question than a geospatial
question but is interesting because it's common to want to plot 2 variables
together. Your question comes at a good time because there has recently
been published a package for solving precisely this problem: *colorspace*.


There are mapping examples in there, but not with raster data. I'm sure you
could use it to solve your problem, however.

Another approach is to use the magick image manipulation package.

Here's some code and an image showing the result.

Code: https://gist.github.com/Robinlovelace/9d9844886ec186c4423b611e6185392e

Resulting image (sorry about the 'pipes' Edzer!): https://flic.kr/p/Mj5cos

I suggest the colorplane package instead of the *magick* way (unless
someone knows of a better solution) at present because it also seems to
create a legend for you.

If you provide a simple, reproducible example to start with, that will
increase the probability of someone helping out.

On Thu, Sep 22, 2016 at 11:51 AM, Vasya Pupkin via R-sig-Geo <
r-sig-geo at r-project.org> wrote:

> Hi guys,
> What I am trying to do is to make a map that would show the areas which
> are hot-dry, hot-wet, cold-dry, cold-wet. I have 2 rasters with
> precipitation and temperature values. And I want to plot them over each
> other so that each extreme combination of the 2 variables (hot-dry,
> hot-wet, cold-dry, cold-wet) would have its own colour with respective
> gradients for the intermediate values on the colour scheme, that will have
> to produce a 2D colour legend. Below please see a link to the concept
> image, that I have produced for explanation. I saw such a thing once and
> thought that was a briliant idea to show how 2 variables interact, but then
> I totally forgot where it was. I have been googling for 2 days - no result.
> Any help is very much welcome - the name of the thing, name of the software
> to do it (how to do it would be marvelous), keywords to google, workarounds
> - anything.
> Concept image:
> https://cloud.mail.ru/public/SHno/98X3czaW5
> Best wishes,
> Vasya.
> _______________________________________________
> 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