dotDensityLayer: Dot Density layer

Description Usage Arguments Details See Also Examples

View source: R/dotDensityLayer.R

Description

Plot a dot density layer.

Usage

1
2
3
4
dotDensityLayer(x, spdf, df, spdfid = NULL, dfid = NULL, var, n = NULL,
  iter = 5, pch = 1, cex = 0.15, type = "random", col = "black",
  legend.pos = "topright", legend.txt = NULL, legend.cex = 0.6,
  legend.col = "black", legend.frame = TRUE, add = TRUE)

Arguments

x

an sf object, a simple feature collection. If x is used then spdf, df, spdfid and dfid are not.

spdf

a SpatialPolygonsDataFrame.

df

a data frame that contains the values to plot. If df is missing [email protected] is used instead.

spdfid

id field in spdf, default to the first column of the spdf data frame. (optional)

dfid

id field in df, default to the first column of df. (optional)

var

name of the numeric field in df to plot.

n

one dot on the map represents n (in var units).

iter

number of iteration to try to locate sample points (see Details).

pch

symbol to use: points.

cex

size of the symbols

type

points allocation method: "random" or "regular" (see Details).

col

color of the points.

legend.pos

"topright", "left", "right", "bottomleft", "bottom", "bottomright". If legend.pos is "n" then the legend is not plotted.

legend.txt

text in the legend.

legend.cex

size of the legend text.

legend.col

color of the text in the legend.

legend.frame

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

add

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

Details

The iter parameter is defined within the spsample function. If an error occurred, increase this value.
The type parameters is defined within the spsample function.

See Also

propSymbolsLayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data("nuts2006")
# Example 1
plot(nuts0.spdf)
dotDensityLayer(spdf = nuts0.spdf, df=nuts0.df,var="pop2008")


# Example 2
mtq <- st_read(system.file("shape/martinique.shp", package="cartography"))
plot(st_geometry(mtq), col = "#B8704D50",border = "white")
dotDensityLayer(x = mtq,  var="P13_POP", pch=20, col = "brown", n = 50)
layoutLayer(title = "Population in Martinique, 2013", 
            sources = "INSEE, 2016", scale = NULL, frame = FALSE,
            theme = "brown.pal")

cartography documentation built on Nov. 17, 2017, 5:12 a.m.