Draw Geographical Maps

USAGE:
map(database, regions)  # simple form
map(database="state", regions=".", xlim=, ylim=, boundary=T, interior=T,
      fill=F, color=1, projection=, parameters=, orientation=,
      resolution=1, type="l", plot=T, add=F, namesonly=F)

database:
character string naming the geographical database from which map is to get its information. Currently the choices may include a "world" map along with four USA databases: "usa" for national boundaries, "state" for state boundaries and "county" for county boundaries and a simplified "state.vbm" map. Detailed documentation for Usa, State, County, State.vbm, and World (the database names with initial capitals) gives more information on the databases.
regions:
character vector that names the polygons to draw. Each database is composed of a collection of polygons, and each polygon has a unique name. When a region is composed of more than one polygon, the individual polygons have the name of the region, followed by a colon and a qualifier, as in michigan:north and michigan:south. Each element of the regions argument is matched as a regular expression against all the polygon names in the database and matches are selected for drawing (but see xlim, ylim and color=, each of which can potentially modify this list). The default selects all polygons in the database.
xlim:
two element numeric vector giving a range of longitudes, expressed in degreees, to which drawing should be restricted. Longitude is measured in degrees east of Greenwich, so that, in particular, locations in the USA have negative longitude. If fill=TRUE, polygons selected by region must be entirely inside the xlim range. The default value of this argument spans the entire longitude range of the database.
ylim:
two element numeric vector giving a range of latitudes, expressed in degrees, to which drawing should be restricted. Latitude is measured in degrees north of the equator, so that, in particular, locations in the USA have positive latitude. If fill=TRUE, polygons selected by region must be entirely inside the ylim rang The default value of this argument spans the entire latitude range of the database.
boundary:
logical flag that says whether to draw boundary segments. A boundary segment is a line segment of the map that bounds only one of the polygons to be drawn. This argument is ignored if fill is TRUE.
interior:
logical flag that says whether to draw interior segments. An interior segment is a line segment of the map that bounds two of the polygons to be drawn. This argument is ignored if fill is TRUE.
fill:
logical flag that says whether to draw lines or fill areas. If FALSE, the lines bounding each region will be drawn (but only once, for interior lines). If TRUE, each region will be filled using colors from the color= argument, and bounding lines will not be drawn.
color:
vector of colors. If fill is FALSE, the first color is used for plotting all lines, and any other colors are ignored. Otherwise, the colors are matched one-one with the polygons that get selected by the region argument (and are reused cyclically, if necessary). A color of NA causes the corresponding region to be deleted from the list of polygons to be drawn. Polygon colors are assigned after polygons are deleted due to values of the xlim and ylim arguments.
projection:
character string that names a map projection to use. See Appendix C of the Reference for a description of this and the next two arguments. 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 for use with the projection argument. This argument is optional only in the sense that certain projections do not require additional parameters. If a projection does require additional parameters, these must be given in the parameters argument. See Appendix C of the Reference for details.
orientation:
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 Reference for details.
resolution:
number that specifies the resolution with which to draw the map. Resolution 0 is the full resolution of the database. Otherwise, just before polylines are plotted they are thinned: roughly speaking, successive points on the polyline 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. Aside from the default type="l", the value type="n" can be used to set up the coordinate system and projection for a map that will be added-to in later calls.
plot:
logical flag that specifies whether plotting should be done. If plot is TRUE the return value of map will not be printed automatically .
add:
logical flag that specifies whether to add to the current plot. If FALSE, a new plot is begun, and a new coordinate system is set up.
namesonly:
logical flag that says whether just the names of selected polygons will be returned as a character vector. If FALSE, map coordinates are returned.

Graphical parameters may also be supplied as arguments to this function (see par).


VALUE:
The polygons selected from database, through the regions, xlim, and ylim arguments, are outlined (fill is FALSE) or filled (fill is TRUE) with the colors in color. Names or coordinates of selected polygons are returned, depending on the value of the namesonly argument.

When namesonly is TRUE, the return value is a character vector of the names of the polygons that were selected for drawing. When namesonly is FALSE, the return value is a list with x and y components. If fill is FALSE, these vectors are the coordinates of successive polylines, separated by NAs. If fill is TRUE, the vectors have coordinates of successive polygons, again separated by NAs. Thus the return value can be handed directly to lines or polygon, as appropriate.

After a call to map for which the projection argument was specified there will be a dataset .Last.projection on frame 0, containing information about the projection used. This will be used for subsequent calls to map; see the documentation for mapproject for further details.


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


REFERENCE:
Richard A. Becker, and Allan R. Wilks, "Maps in S", AT&T Bell Laboratories Statistics Research Report, 1991.