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-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to