R/Making Maps

From QERM Wiki
(Redirected from R/Making Inset Maps)
Jump to: navigation, search


Inset maps

It is sometimes useful to add smaller plots within a greater region. An obvious useful application of this is when making maps. An inset map is useful to show where in the world the piece of the world you are working on is. The key code to know is:

  • plt is a parameter which fixes the area within which you want to plot in terms of a vector of the form c(x1, x2, y1, y2) giving the coordinates of the plot region as fractions of the current figure region.
  • new=TRUE says not to create a new plot (kind of counter-intuitively) but to use the existing space and overlay the subsequent commands.

Look at Rlogo.jpg the code here to see how to produce an image that looks like:


More detailed coastlines

The worldHires database accessed by the "maps" package in R is based on the CIA World Data Bank II (available here: http://www.evl.uic.edu/pape/data/WDB/). More detailed coastline data can be obtained using the USGS coastline extractor: http://rimmer.ngdc.noaa.gov/. However, this data may need to be reconfigured to make continuous filled polygons in R.


Great help, thanks guys! One note though, I had to add plot.new() before plot.window() to make this work correctly (Liz)

See also

R tips

Personal tools