Skip to content

side-by-side map with different geographies using spplot

2 messages · David Epstein, Roger Bivand

#
Hello,

I want to create side-by-side maps of similar attribute data in two 
different cities using a single legend.

To simply display side-by-side census block group boundary 
(non-thematic) maps for Minneapolis & Cleveland I do the following:

library(rgdal)
library(sp)
Minneapolis=readOGR("../Minneapolis/Census/2010/Census_BlockGroup_GEO/","tl_2010_27053_bg10")
Cleveland=readOGR("../Cleveland/Census/2010/Census_BlockGroup_GEO/","tl_2010_39035_bg10")
par(mfrow=c(1,2))
plot(Minneapolis)
plot(Cleveland)

I can display a single thematic map for a city using spplot as follows:

spplot(Minneapolis,"Thematic_Data_Column")

But, calling the function again for Cleveland just overwrites the 
window. I am unsure how to use spplot's layout tools with two different 
geographies. Most examples use a single geography and multiple attribute 
columns. Alternatively, is there a way to use "par" together with spplot 
to allow for multiple spplot calls?

thank you,
-david
#
David Epstein <davideps <at> umich.edu> writes:
....
The spplot function uses lattice graphics, so you may use the standard methods
for the "trellis" objects that it returns. If you did something like:

sp_out_Minneapolis <- spplot(Minneapolis, "your_var")
print(sp_out_Minneapolis, split=c(1, 1, 2, 1), more=TRUE)
sp_out_Cleveland <- spplot(Cleveland, "your_var")
print(sp_out_,Cleveland split=c(2, 1, 2, 1), more=FALSE)

you will get some of the way there. If in addition you would like only one
legend using the same breaks and colours, you'll need to use appropriate
arguments to spplot() in both calls to handle this.

It may be worth considering posting queries of this kind on R-sig-geo, as
response may be forthcoming more quickly there.

Hope this helps,

Roger