mf_map: Plot a map

View source: R/mf_map.R

mf_mapR Documentation

Plot a map

Description

This is the main function of the package. mf_map() can be used to plot all types of maps.
The three main arguments are: x (sf object), var (variable to map), and type (map type).
Relevant arguments and default values for each map types are detailed in specific functions, see Details.

Usage

mf_map(
  x,
  var,
  type = "base",
  breaks,
  nbreaks,
  pal,
  alpha,
  rev,
  inches,
  val_max,
  symbol,
  col,
  lwd_max,
  val_order,
  pch,
  cex,
  border,
  lwd,
  col_na,
  cex_na,
  pch_na,
  expandBB,
  add,
  leg_pos,
  leg_title,
  leg_title_cex,
  leg_val_cex,
  leg_val_rnd,
  leg_no_data,
  leg_frame,
  leg_frame_border,
  leg_horiz,
  leg_adj,
  leg_bg,
  leg_fg,
  leg_size,
  leg_border,
  leg_box_border,
  leg_box_cex,
  ...
)

Arguments

x

object of class sf or sfc

var

name(s) of the variable(s) to plot

type
  • base: base maps

  • prop: proportional symbols maps

  • choro: choropleth maps

  • typo: typology maps

  • symb: symbols maps

  • grad: graduated symbols maps

  • prop_choro: proportional symbols maps with symbols colors based on a quantitative data classification

  • prop_typo: proportional symbols maps with symbols colors based on qualitative data

  • symb_choro: symbols maps with symbols colors based on a quantitative data classification

breaks

either a numeric vector with the actual breaks, or a classification method name (see mf_get_breaks and Details)

nbreaks

number of classes

pal

a set of colors or a palette name (from hcl.colors)

alpha

if pal is a hcl.colors palette name, the alpha-transparency level in the range [0,1]

rev

if pal is a hcl.colors palette name, whether the ordering of the colors should be reversed (TRUE) or not (FALSE)

inches

size of the biggest symbol (radius for circles, half width for squares) in inches.

val_max

maximum value used for proportional symbols

symbol

type of symbols, 'circle' or 'square'

col

color

lwd_max

line width of the largest line

val_order

values order, a character vector that matches var modalities

pch

point type

cex

point size

border

border color

lwd

border width

col_na

color for missing values

cex_na

cex (point size) for NA values

pch_na

pch (point type) for NA values

expandBB

fractional values to expand the bounding box with, in each direction (bottom, left, top, right)

add

whether to add the layer to an existing plot (TRUE) or not (FALSE)

leg_pos

position of the legend, one of 'topleft', 'top','topright', 'right', 'bottomright', 'bottom', 'bottomleft', 'left' or a vector of two coordinates in map units (c(x, y)). If leg_pos = NA then the legend is not plotted. If leg_pos = 'interactive' click onthe map to choose the legend position.

leg_title

legend title

leg_title_cex

size of the legend title

leg_val_cex

size of the values in the legend

leg_val_rnd

number of decimal places of the values in the legend

leg_no_data

label for missing values

leg_frame

whether to add a frame to the legend (TRUE) or not (FALSE)

leg_frame_border

border color of the legend frame

leg_horiz

display the legend horizontally (for proportional symbols and choropleth types)

leg_adj

adjust the postion of the legend in x and y directions

leg_bg

color of the legend backgournd

leg_fg

color of the legend foreground

leg_size

size of the legend; 2 means two times bigger

leg_border

symbol border color(s)

leg_box_border

border color of legend boxes

leg_box_cex

width and height size expansion of boxes

...

further parameters from plot for sfc objects

Details

Relevant arguments, default values and examples for each map types are detailed in specific functions:

  • base: base maps - mf_base

  • prop: proportional symbols maps - mf_prop

  • choro: choropleth maps - mf_choro

  • typo: typology maps - mf_typo

  • symb: symbols maps - mf_symb

  • grad: graduated symbols maps - mf_grad

  • prop_choro: proportional symbols maps with symbols colors based on a quantitative data classification - mf_prop_choro

  • prop_typo: proportional symbols maps with symbols colors based on qualitative data - mf_prop_typo

  • symb_choro: symbols maps with symbols colors based on a quantitative data classification - mf_symb_choro

Breaks defined by a numeric vector or a classification method are left-closed: breaks defined by c(2, 5, 10, 15, 20) will be mapped as [2 - 5[, [5 - 10[, [10 - 15[, [15 - 20]. The "jenks" method is an exception and has to be right-closed. Jenks breaks computed as c(2, 5, 10, 15, 20) will be mapped as [2 - 5], ]5 - 10], ]10 - 15], ]15 - 20].

Value

x is (invisibly) returned.

Examples

mtq <- mf_get_mtq()
mf_map(mtq)
mf_map(mtq, var = "POP", type = "prop")
mf_map(mtq, var = "MED", type = "choro")
mf_map(mtq, var = "STATUS", type = "typo")
mf_map(mtq)
mf_map(mtq, var = "STATUS", type = "symb")
mf_map(mtq)
mf_map(mtq, var = "POP", type = "grad")
mf_map(mtq)
mf_map(mtq, var = c("POP", "MED"), type = "prop_choro")
mf_map(mtq)
mf_map(mtq, var = c("POP", "STATUS"), type = "prop_typo")
mf_map(mtq)
mf_map(mtq, var = c("STATUS", "MED"), type = "symb_choro")

mapsf documentation built on Nov. 21, 2023, 5:09 p.m.