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.liakhovit...@gmail.com> wrote:
> 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@data[["groups"]]<-1   # want all provinces to have the same
> color, but ideally I'd like the whole map to be transparent.
> can1@data$groups<-as.factor(can1@data$groups)
> 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@data[["groups"]]<-groups
> can2@data$groups<-as.factor(can2@data$groups)
> 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@r-project.org mailing list
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.

Reply via email to