Here is one way: library(maps) par(mfrow=c(1,2)) ##Map 1: State with counties that are the study region map("state","washington",fill=T,col="white",names=TRUE,plot=T) co=map("county",region=c("washington,chelan","washington,douglas","washington,okanogan","washington,grant"),col="gray",bg="gray",fill=T,plot=F) polygon(co$x,co$y,col="darkgray",border="darkgray") ##Map 2: The study region, large in order to plot some study sites from lat & long
x1 <- rep(range(co$x, na.rm=TRUE),2) y1 <- rep(range(co$y, na.rm=TRUE),each=2) xt1 <- grconvertX(x1, to='ndc') yt1 <- grconvertY(y1, to='ndc') c2=map("county",region=c("washington,chelan","washington,douglas","washington,okanogan","washington,grant"),fill=T,col="white",names=TRUE,plot=F) map("county",region=c("washington,chelan","washington,douglas","washington,okanogan","washington,grant"),fill=T,col="white") xtt1 <- grconvertX(xt1, from='ndc') ytt1 <- grconvertY(yt1, from='ndc') par(xpd=NA) segments(x1,y1,xtt1,ytt1, col='red') This draws from the corners of the bounding box, change x1 and y1 for different points to connect. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-sig-geo-boun...@stat.math.ethz.ch [mailto:r-sig-geo- > boun...@stat.math.ethz.ch] On Behalf Of frosty goat > Sent: Friday, November 05, 2010 12:45 PM > To: r-sig-geo@stat.math.ethz.ch > Subject: [R-sig-Geo] Map duo with lines connecting them > > > Hi, I wish to combine two maps on a single plot so that I can draw > lines that > interact with each map. The maps are easily plotted side by side with > par(mfrow=c(1,2) or layout(matrix(c(1,2,1,2),2,2,byrow=T), BUT I don't > think > there is a way to plot the lines that interact with each. > > Here is the code that will give you the idea of what I want to do: > > library(maps) > #layout(matrix(c(1,2,1,2),2,2,byrow=T)) > #par(mfrow=c(1,2)) > ##Map 1: State with counties that are the study region > map("state","washington",fill=T,col="white",names=TRUE,plot=T) > co=map("county",region=c("washington,chelan","washington,douglas","wash > ington,okanogan","washington,grant"),col="gray",bg="gray",fill=T,plot=F > ) > polygon(co$x,co$y,col="darkgray",border="darkgray") > ##Map 2: The study region, large in order to plot some study sites from > lat > & long > c2=map("county",region=c("washington,chelan","washington,douglas","wash > ington,okanogan","washington,grant"),fill=T,col="white",names=TRUE,plot > =F) > > > So, I would like lines to go from the corners of the study region on > the > state (overview) map to the corners on the bigger detailed study > regions on > the second map, so it looks like it is popping out. > > This seems to require the two maps to be one single map unified by the > coordinates, but clearly the state map covers a much broader lat and > long > range. > > Thanks for any ideas. > > > > > -- > View this message in context: http://r-sig- > geo.2731867.n2.nabble.com/Map-duo-with-lines-connecting-them- > tp5710206p5710206.html > Sent from the R-sig-geo mailing list archive at Nabble.com. > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo