[R-sig-Geo] create inset map
dieter Vanderelst
dieter.vanderelst at gmail.com
Sat Oct 15 17:01:29 CEST 2011
Hello List,
I have a map of Africa I plot using spplot(). In addition, I have a second map of Sao Tome (a small island). I want to add this second map to the first as an inset because it would otherwise not be visible at the same scale of the continent.
This is what I currently do: I save both maps to a variable and plot them using the print.trellis function (see http://stat.ethz.ch/R-manual/R-devel/library/lattice/html/print.trellis.html).
This is the code:
p1<-spplot(Africa,c('var1'))
p2<-spplot(Sao,c('var1'))
print(p1,position=c(0,0,1,1),more=T)
print(p2,position=c(0,0,0.3,0.3),more=T)
This results is a map of Africa with a second map of Sao in the left bottom corner.
However, the location of the inset in the larger map is difficult to control using this code. Spplot enforces the aspect ratio of the maps to be respected. Of course, this is necessary for mapping. However, this seems to conflict with the position arguments in the print statements.
Does anybody have some which allows controlling the location of an inset map in a larger map?
Regards,
Dieter
More information about the R-sig-Geo
mailing list