Draw Geographical Maps

DESCRIPTION:

Constructs U.S. and world maps. This function is part of the maps library. To make it available in your Spotfire S+ session, use the command library(maps).

USAGE:

map(database, regions)
map(database="state", regions=".", xlim, ylim, boundary=T, interior=T, 
      fill=F, color=1, projection="", parameters=NULL, orientation=c(90,0,m), 
      resolution=1, type="l", plot=T, add=F, namesonly=F, exact=T, ...) 

ARGUMENTS:

database
character string naming a geographical database. Current choices include the world database along with four U.S.A. databases: usa draws national boundaries, state draws state boundaries, county draws county boundaries, and state.vbm constructs a Visibility Base Map of the United States. Detailed documentation can be found in the help files for World, Usa, State, County, and State.vbm (i.e., the database names with initial capital letters).
regions
character vector naming the polygons to draw. Each geographical database is composed of a collection of polygons that have unique names. When a region is composed of more than one polygon, the name includes the name of the region followed by a colon and a qualifier; "michigan:north" and "michigan:south" are examples. Each element of the regions argument is matched as a regular expression against all the polygon names in the chosen database, and matches are selected for drawing. The default selects all polygons in the database.

The xlim, ylim and color arguments can potentially modify the list of polygons to draw. See below for descriptions of these arguments.
xlim
two-element numeric vector specifying a range of longitudes (expressed in degrees) to which drawing should be restricted. Longitude is measured in degrees east of Greenwich, so that locations in the U.S. have negative longitude, for example. If fill=TRUE, polygons selected by regions must be completely inside the xlim range. The default spans the entire longitude range of the chosen database.
ylim
two-element numeric vector specifying a range of latitudes (expressed in degrees) to which drawing should be restricted. Latitude is measured in degrees north of the equator, so that locations in the U.S. have positive latitude, for example. If fill=TRUE, polygons selected by regions must be completely inside the ylim range. The default spans the entire latitude range of the chosen database.
boundary
logical flag: should boundary segments be drawn? A boundary segment is a line on the map that bounds only one of the polygons to be drawn. This argument is ignored if fill=TRUE.
interior
logical flag: should interior segments be drawn? An interior segment is a line on the map that bounds two of the polygons to be drawn. This argument is ignored if fill=TRUE.
fill
logical flag: should polygons be filled? If fill=FALSE, the lines bounding each region are drawn. If fill=TRUE, each region is filled using colors from the color argument, and bounding lines are not drawn.
color
vector of colors. If fill=FALSE, the first color is used for plotting all lines and any other colors are ignored. Otherwise, the colors are matched in order with the polygons selected by the regions argument, and are reused cyclically if necessary. Polygon colors are assigned after polygons are deleted (i.e., after the xlim and ylim arguments are applied). A color of NA causes the corresponding region to be deleted from the list of polygons to be drawn.
projection
character string naming a map projection to use. See Appendix C of the reference for a description of this argument. The default is to use a rectangular projection, with the aspect ratio chosen so that longitude and latitude scales are equivalent at the center of the picture.
parameters
numeric vector of parameters to use with the projection argument. This argument is not required for all projections, as certain projections do not need additional parameters. See Appendix C of the reference for details.
orientation
vector containing up to three numbers specifying the orientation of non-standard projections. Default is c(90,0,m), where m is the middle of the longitude range. See Appendix C of the reference for details.
resolution
number that specifies the resolution with which to draw the map. A resolution of 0 is the full resolution of the database. Otherwise, successive points on the polygon lines that are within resolution device pixels of one another are collapsed to a single point. See the reference for further details.
type
character string that controls drawing of the map. For example, the value type="n" can be used to set up the coordinate system and projection for a map that will be modified in later calls.
plot
logical flag: should a plot be generated? If plot=TRUE, the return value of map is not printed automatically.
add
logical flag: should the current plot be added to? If add=FALSE, a new plot is generated on a new coordinate system.
namesonly
logical flag: should the names of selected polygons be returned as a character vector? If namesonly=FALSE, map coordinates are returned.
exact
logical flag: if TRUE then exact matching of regions in the database will be done, otherwise, partial matching will be done.
...
Graphical parameters may also be supplied as arguments to the map function; see for details.

VALUE:

The polygons selected from database, through the regions, xlim , and ylim arguments, are outlined if fill=FALSE and filled if fill=TRUE. The colors used in drawing the polygons are specified by the color argument.

Names or coordinates of the selected polygons are returned, depending on the value of the namesonly argument. When namesonly=TRUE, the return value is a character vector of the names of the polygons that were selected for drawing. When namesonly=FALSE, the return value is a list with x and y components that contain the coordinates of the selected polygons. If fill=FALSE, the return vectors are the coordinates of successive polygon lines, separated by NAs. If fill=TRUE, the vectors are coordinates of successive polygons, again separated by NAs. Thus, the return value can be passed directly to lines or polygon, as appropriate.

After a call to map in which the projection argument is specified, a data set called .Last.projection is created on frame 0. This data set contains information about the projection and is used in subsequent calls to map. For further details, see the documentation for mapproject.

REFERENCES:

Becker, R. A. and Wilks, A. R. (1991). Maps in S. AT&T Bell Laboratories Statistics Research Report.

EXAMPLES:

# load the maps library
library(maps)
# state map of the USA 
map()
# national boundaries 
map("usa")      
# county map of New Jersey 
map("county", "new jersey")     
# map of three states 
map(regions=c("new york","new jersey","penn"))
# Bonne equal-area projection of the USA        
map(proj="bonne", param=45)
# names of the San Juan islands in Washington state 
map("county", "washington,san", names=T, plot=F) 
# plot the ozone data on a base map 
map(xlim=range(ozone.xy$x), ylim=range(ozone.xy$y)) 
text(ozone.xy, labels=ozone.median) 
# national boundaries in one color, states in another   
map(interior=F)
map(boundary=F, lty=2, add=T)