Learn R Programming

McSpatial (version 1.1.1)

mapplot: Maps for Shape File Data

Description

A simple interface to the SP package's spplot command

Usage

mapplot(shpfile,varname,brks=8,col="RdBu",sampvar=NULL,print=TRUE,title=NULL)

Arguments

shpfile
The shape file
varname
The name of the variable to be plotted. Must be in quotation marks.
brks
Either the number of break points or a vector of break points for the intervals shown on the map.
col
Color scheme for the map. All of RColorBrewer's schemes are available, e.g., "Blues", "BuGn", "BuPu", and "GnBu". Default: "RdBu"
sampvar
A variable indiciating which observations to include in the map. Tracts for which sampvar=F will not be drawn.
print
If print=T, prints the endpoints for the intervals shown on the map. Default: print=T.
title
A title for the map.

See Also

mapoverlay mappoints

Examples

Run this code
library(maptools)
cmap <- readShapePoly(system.file("maps/CookCensusTracts.shp",package="McSpatial"))
cmap$lnpopdens <- log(cmap$POPULATION/cmap$AREA)
mapplot(cmap,"lnpopdens",sampvar=cmap$AREA>0&cmap$POPULATION>0,col="Blues",
  title="Log of Population Density")

Run the code above in your browser using DataLab