I would like to represent multiple counties in TN state as a single region using a common color fill. I can do that with the code below:
library(maps)
map("state", "tennessee", fill = TRUE, col="white", names = TRUE, plot = TRUE)
co <- map("county",region = c("tennessee,williamson","tennessee,davidson",
"tennessee,wilson","tennessee,cheatham"),
col = "red", bg = "blue", fill = TRUE, plot = FALSE)
polygon(co$x, co$y, col = "yellow", border = "black")
But the black borders are drawn inside my region of interest. Is there a way to define the polygon function such that common county borders are not drawn in black?
Thank you.
map.poly() with as.polygon=FALSE, and then plot this with lines(). map.poly() with as.polygon=TRUE and then plot this with polygon() and border=FALSE.You can see this if you look through the code of map by just entering it at the command line and hitting enter.
Here is the code I used to get what you want:
map("state","tennessee",fill=T,col="white",names=T,plot=T)
coords = map.poly("county",region=c("tennessee,williamson","tennessee,davidson","tennessee,wilson","tennessee,cheatham"), boundary=T, interior=F, fill=F, as.polygon=T)
polygon(coords, col='red', border=F)
map("county",region=c("tennessee,williamson","tennessee,davidson","tennessee,wilson","tennessee,cheatham"),fill=F,interior=F,add=T)

From reading ?map, I thought simply doing something like map(..., interior=F, fill=T, col='red') would work, but this doesn't seem to do it. Could be a bug, but I haven't played with this package enough to know for sure...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With