When plotting simple geographical data (lon,lat) in R, a background map may be useful. Some R-integrated examples are described here with different levels of detail in maps, scaling, and axis decorations. Besides 'ggplot2' and 'rworldmap', several libraries might be required from CRAN, such as 'maps' and 'mapproj'.
Low-resolution world map
Code Block |
---|
library(ggplot2) worlddata <- map_data("world") # possible to choose regions see ?world worldmap <- ggplot(worlddata, aes(x=long, y=lat, group=group)) + geom_polygon() + scale_y_continuous(breaks=(-2:2) * 30) + scale_x_continuous(breaks=(-4:4) * 45) # Orthographic projection with default orientation (looking down at North pole) worldmap + coord_map("ortho") # Centered on North Sea region worldmap + coord_map("ortho", orientation=c(55, 10, 0)) xxlim <- c(-7,12) ## selected range North Sea yylim <- c(48,62) worldmap + coord_cartesian(xlim = xxlim, ylim = yylim) worldmap + coord_cartesian(xlim = xxlim, ylim = yylim) + theme(axis.text = element_blank(), axis.title = element_blank(), axis.line = element_blank(), axis.ticks = element_blank()) |
Higher resolution maps using package rworldmap and rworldxtra
More info at http://journal.r-project.org/archive/2011-1/RJournal_2011-1_South.pdf
...