[R-sig-Geo] semi-transparent mapping - overlapping areas

Juta Kawalerowicz juta.kawalerowicz at stx.ox.ac.uk
Thu Apr 26 00:54:52 CEST 2012


Dear Roger and Roman, 

Thanks for answering, with your kind help  I compiled the maps I wanted.

Best wishes, 
Juta
________________________________________
From: Roger Bivand [Roger.Bivand at nhh.no]
Sent: 25 April 2012 11:34
To: Roman Luštrik
Cc: Juta Kawalerowicz; r-sig-geo [r-sig-geo at r-project.org]
Subject: Re: [R-sig-Geo] semi-transparent mapping - overlapping areas

On Wed, 25 Apr 2012, Roman Luštrik wrote:

> You could use the alpha argument to set transparency to each color. The
> overlaying colors should have a mixture of both. For example, see the
> bottom two images (http://had.co.nz/ggplot2/geom_histogram.html) of how
> alpha mixing works. Lattice graphics also have an alpha argument.
>

Right. In base graphics:

library(maptools)
set.seed(1)
xx <- readShapeSpatial(system.file("shapes/sids.shp",
  package="maptools")[1], proj4string=CRS("+proj=longlat"))
xx$reds <- 1
is.na(xx$reds) <- sample(1:100, 50)
xx$blues <- 1
is.na(xx$blues) <- sample(1:100, 50)
plot(xx, col="grey80", border="transparent")
plot(xx, col=ifelse(is.na(xx$reds), "transparent", "red"),
  border="transparent", add=TRUE)
plot(xx, col=ifelse(is.na(xx$blues), "transparent",
  rgb(red=0, green=0, blue=1, alpha=0.5)), border="transparent",
  add=TRUE)

with rather too brutal red/blue colours.

Roger

>
> Cheers,
> Roman
>
>
> On Wed, Apr 25, 2012 at 12:13 PM, Juta Kawalerowicz <
> juta.kawalerowicz at stx.ox.ac.uk> wrote:
>
>> Hi,
>>
>>
>>
>> Does anyone know how to create mapping of attribute A and attribute B so
>> that the overlapping areas are not colour A or B but the mixture of the two
>> (the semi-transparent effect). In case that does not sound clear, I am
>> looking for this kind of effect
>>
>>
>>
>> http://tinyurl.com/cko7c4b created by Divid McCandless (probably not
>> using R?)
>>
>>
>>
>> If anyone knows a function/package which could allows to do something like
>> this, I would be very gretful for suggestions.
>>
>>
>>
>> Cheers,
>>
>> Juta
>>
>>        [[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
>>
>
>
>
>

--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list