Java Mailing List Archive

http://www.r-help.com/

Home » R Help for Statistical Computing »

Re: [R] Overimposing one map in ssplot onto another

Dimitri Liakhovitski

2012-01-27

Replies: Find Java Web Hosting

Author LoginPost Reply
Sorry, I meant to send it to the map R list, but sent it here by mistake.
Still, if someone could help, it'd be great!
Thank you!

On Fri, Jan 27, 2012 at 12:49 PM, Dimitri Liakhovitski
<dimitri.liakhovitski@(protected):
> Hello!
>
> I have 2 maps - both created in ssplot and both identical in terms of
> outline. Is there any way to superimpose Map1 (which has black borders
> between Canadian provinces) onto Map2 (which is also a map of Canada)?
> Thanks a lot for your hints!
> Dimitri
>
> ### A. Reading in Canada data at the province and then at the county level:
> library(raster)
> getData('ISO3')  # Canada's code is "CAN"
> can1<-getData('GADM', country="CAN", level=1)
> can2<-getData('GADM', country="CAN", level=2)
>
> ### B. Creating Map1- with borders between provinces:
> can1@(protected)
> color, but ideally I'd like the whole map to be transparent.
> can1@data$groups<-as.factor(can1@(protected))
> spplot(can1,zcol="groups",col.regions="white",colorkey = FALSE,
> lwd=.4,  # col='white',
>  par.settings = list(axis.line = list(col='transparent')))
>
> ### C. Creating Map2- with borders between colored counties:
> # Creating an (artificial) grouping of Canadian admin units:
> nrofunits<-length(can2$NAME_2)
> groups<-c(rep(1:6,(nrofunits %/%
> 6)),rep(1,5))[order(c(rep(1:6,(nrofunits %/% 6)),rep(1,5)))]
> # adding values (grouping values) to "data":
> can2@(protected)
> can2@data$groups<-as.factor(can2@(protected))
> classcolors <- rainbow(6)
> spplot(can2,zcol="groups",col.regions=classcolors,colorkey =
> FALSE,lwd=.4,col='white',
>  par.settings = list(axis.line = list(col='transparent')))
>
> --
> Dimitri Liakhovitski
> marketfusionanalytics.com



--
Dimitri Liakhovitski
marketfusionanalytics.com

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
©2008 r-help.com - Jax Systems, LLC, U.S.A.