mapplot             package:latticeExtra             R Documentation

_T_r_e_l_l_i_s _d_i_s_p_l_a_y_s _o_n _M_a_p_s _a._k._a. _C_h_o_r_o_p_l_e_t_h _m_a_p_s

_D_e_s_c_r_i_p_t_i_o_n:

     Produces Trellis displays of numeric (and eventually categorical)
     data on a map.  This is largely meant as a demonstration, and
     users looking for serious map drawing capabilities should look
     elsewhere (see below).

_U_s_a_g_e:

     mapplot(x, data, ...)

     ## S3 method for class 'formula':
     mapplot(x, data, map, outer = TRUE,
             prepanel = prepanel.mapplot,
             panel = panel.mapplot,
             aspect = "iso",
             legend = NULL,
             breaks, cuts = 30,
             colramp = colorRampPalette(brewer.pal(n = 11, name = "Spectral")),
             colorkey = TRUE,
             ...)

     prepanel.mapplot(x, y, map, ...)
     panel.mapplot(x, y, map, breaks, colramp, lwd = 0.5, ...)

_A_r_g_u_m_e_n_t_s:

    x, y: For 'mapplot', an object on which method dispatch is carried
          out.  For the formula method, a formula of the form 'y ~ x',
          with additional conditioning variables as desired.  The
          extended form of conditioning using 'y ~ x1 + x2' etc. is
          also allowed.  The formula might be interpreted as in a dot
          plot, except that 'y' is taken to be the names of
          geographical units in 'map'.

          Suitable subsets (packets) of 'x' and 'y' are passed to the
          prepanel and panel functions. 

    data: A data source where names in the formula are evaluated 

     map: An object of class '"map"' (package 'maps'), containing
          boundary information.  The names of the geographical units
          must match the 'y' variable in the formula.  

   outer: logical; how variables separated by '+' in the formula are
          interpreted.  It is not advisable to change the default.  

prepanel, panel: the prepanel and panel functions 

  aspect: aspect ratio

breaks, cuts, colramp: controls conversion of numeric 'x' values to a
          false colo.  'colramp' may be a vector of colors or a
          function that produces colors (such as 'cm.colors') 

legend, colorkey: controls legends; usually just a color key giving the
          association between numeric values of 'x' and color.  

     lwd: line width

     ...: Further arguments passed on to the underlying engine. See
          'xyplot' for details.  

_V_a_l_u_e:

     An object of class '"trellis"'.

_N_o_t_e:

     This function is meant to demonstrate how maps can be incorporated
     in a Trellis display.  Users seriously interested in geographical
     data should consider using software written by people who know
     what they are doing.

_A_u_t_h_o_r(_s):

     Deepayan Sarkar

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://en.wikipedia.org/wiki/Choropleth_map>

_S_e_e _A_l_s_o:

     'Lattice'

_E_x_a_m_p_l_e_s:

     library(maps)
     library(mapproj)

     data(USCancerRates)

     mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
             data = USCancerRates,
             map = map("county", plot = FALSE, fill = TRUE,
                       projection = "mercator"))

     mapplot(rownames(USCancerRates) ~ log(rate.male) + log(rate.female),
             data = USCancerRates,
             map = map("county", plot = FALSE, fill = TRUE,
                       projection = "tetra"),
             scales = list(draw = FALSE))

     data(ancestry)

     county.map <- 
         map('county', plot = FALSE, fill = TRUE, 
             projection = "azequalarea")

     mapplot(county ~ log10(population), ancestry, map = county.map)

     ## Not run: 

     ## this may take a while (should get better area records)

     county.areas <- 
         area.map(county.map, regions = county.map$names, sqmi = FALSE)
         
     ancestry$density <- 
         with(ancestry, population / county.areas[as.character(county)])

     mapplot(county ~ log(density), ancestry,
             map = county.map, border = NA,
             colramp = colorRampPalette(c("white", "black")))

     ## End(Not run)

