Learn R Programming

tmap (version 1.4-1)

qtm: Quick thematic map plot

Description

Draw a thematic map quickly.

Usage

qtm(shp, fill = NA, bubble.size = NULL, bubble.col = NULL, dot.col = NULL, text = NULL, text.size = 1, text.col = NA, line.lwd = NULL, line.col = NULL, raster = NA, borders = NA, scale = NA, title = NA, projection = NULL, format = NULL, style = NULL, basemaps = NA, ...)

Arguments

shp
shape object, which is one of
  1. SpatialPolygons(DataFrame)
  2. SpatialPoints(DataFrame)
  3. SpatialLines(DataFrame)
  4. SpatialGrid(DataFrame)
  5. SpatialPixels(DataFrame)
  6. RasterLayer, RasterStack, or RasterBrick

In "view" mode (see tmap_mode) there are two other options. 1) If omitted, an interactive map without thematic layers is opened. 2) In addition, if a character is provided, this character is used as a search query for OpenStreetMap nominatim. This will position the interactive map accordingly. Arguments of tm_view, such as set.view can be passed on directly.

fill
either a color to fill the polygons, or name of the data variable in shp to draw a choropleth. Only applicable when shp is type 1 (see above).
bubble.size
name of the data variable in shp for the bubble map that specifies the sizes of the bubbles. If neither bubble.size nor bubble.col is specified, no bubble map is drawn. Only applicable when shp is type 1, 2, or 3 (see above).
bubble.col
name of the data variable in shp for the bubble map that specifies the colors of the bubbles. If neither bubble.size nor bubble.col is specified, no bubble map is drawn. Only applicable when shp is type 1, 2, or 3 (see above).
dot.col
name of the data variable in shp for the dot map that specifies the colors of the dots.
text
Name of the data variable that contains the text labels. Only applicable when shp is type 1, 2, or 3 (see above).
text.size
Font size of the text labels. Either a constant value, or the name of a numeric data variable. Only applicable when shp is type 1, 2, or 3 (see above).
text.col
name of the data variable in shp for the that specifies the colors of the text labels. Only applicable when shp is type 1, 2, or 3 (see above).
line.lwd
either a line width or a name of the data variable that specifies the line width. Only applicable when shp is type 3 (see above).
line.col
either a line color or a name of the data variable that specifies the line colors. Only applicable when shp is type 3 (see above).
raster
either a color or a name of the data variable that specifices the raster colors. Only applicable when shp is type 4, 5, or 6 (see above).
borders
color of the polygon borders. Use NA to omit the borders.
scale
numeric value that serves as the global scale parameter. All font sizes, bubble sizes, border widths, and line widths are controled by this value. The parameters bubble.size, text.size, and line.lwd can be scaled seperately with respectively bubble.scale, text.scale, and line.scale.
title
main title. For legend titles, use X.style, where X is layer name (see ...).
projection
character that determines the projection. Either a PROJ.4 character string or a shortcut. See get_proj4 for a list of shortcut values. By default, the projection is used that is defined in the shp object itself, which can be obtained with get_projection.
format
tm_layout wrapper used for format. Currently available in tmap: "World", "Europe", "NLD", "World_wide", "Europe_wide", "NLD_wide". Own wrappers can be used as well (see details).
style
tm_layout wrapper used for style. Available in tmap: "bw", "classic". Own wrappers can be used as well (see details).
basemaps
basemaps for the view mode. See tm_view
...
arguments passed on to the tm_* functions. If an argument name is not unique for a particular tm_ function, then it should be prefixed with the function name without "tm_". For instance, style is an argument of tm_fill, tm_bubbles, and tm_lines. Therefore, in order to define the style for a choropleth, its arugment name should be fill.style.

Value

tmap-element

Details

This function is a convenient wrapper of the main plotting method of stacking tmap-elements. The first argument is a shape object (normally specified by tm_shape). The next arguments, from fill to raster, are the aesthetics from the main layers. The remaining arguments are related to the map layout. Any argument from any main layer can be specified (see ...). It is also possible to stack tmap-elements on a qtm plot. See examples.

For format any character value, say "xxx" can be used if the wrapper function "tm_format_xxx" exists. The same applies for the arguments colors, and style.

See Also

vignette("tmap-nutshell")

Examples

Run this code
data(World, rivers, metro)

# just the map
qtm(World)

# choropleth
qtm(World, fill = "economy", format="World", style="col_blind")

qtm(World, fill="HPI", fill.n=9, fill.palette="div", fill.auto.palette.mapping=FALSE, 
	fill.title="Happy Planet Index", format="World", style="gray")

# bubble map
qtm(World, borders = NULL) + qtm(metro, bubble.size = "pop2010", 
    bubble.title.size="Metropolitan Areas", bubble.scale=.5, format = "World")

# TIP: check out these examples in view mode, enabled with tmap_mode("view")

Run the code above in your browser using DataLab