Learn R Programming

NipponMap (version 0.2)

JapanPrefMap: A simple choropleth map of Japan

Description

Draw a very simple choropleth map of Japan with prefecture boundaries

Usage

JapanPrefMap(col = NULL, inset = TRUE, ...)

Arguments

col

A character vector. RGB or named colors in order of JISCODE to fill a polygon of 47 prefectures.

inset

logical. if TRUE, Okinawa Prefecture is shown in a inset map. The default value is TRUE.

...

any other options passed to plot method of Simple features class.

Value

A matrix. The coordinates of a label point in each prefecture.

Details

The function JapanPrefMap draws a simple choropleth map of Japan in prefecture level with or without inset of Okinawa Prefecture. This feature is most frequently desired by Japanese R users but has been difficult to draw with R functions, for example, map('japan') in mapdata package. What is important is that this function receives a color vector in order of JIS code of prefectures. Since most official statistics by prefecture is in order of the JIS code, users simply create a color sequence for a choropleth map without any rearranging the order. Users are now freed from a trouble in applying order or merge functions to their data set.

Population set was retrieved from 2010 Population Census of Japan.

See Also

cshp in cshapes package, japan in mapdata package.

Examples

Run this code
# NOT RUN {
JapanPrefMap()

if (requireNamespace("RColorBrewer", quietly = TRUE)) {
  cols <- rev(RColorBrewer::brewer.pal(8,"Set2"))
}else{
  cols <- sample(colours(), 47)
}
JapanPrefMap(col = cols, border = gray(.8), axes = TRUE)

if (requireNamespace("foreign", quietly = TRUE)) {
dat <- foreign::read.dbf(system.file("shapes/jpn.dbf", package="NipponMap"))
op <- par(bg = "skyblue")
p <- JapanPrefMap(col = "ivory")
col <- c("olivedrab4", "olivedrab1")
pop <- dat$population / 1e+7
symbols(p, circles = sqrt(pop / (2 * pi)), inches = FALSE,
    fg = col[1], bg = col[2], add = TRUE)
idx <- c(1e+6, 5e+6, 1e+7)
pos <- legend("bottomright", legend = format(idx, scientific = 10, big.mark = ","),
    title = "Population (2010)", bg = "white", x.intersp = 2, y.intersp = 1.5)
symbols(pos$text$x - 1, pos$text$y, circles = sqrt(idx / 1e+7 / (2 * pi)),
    inches = FALSE, fg = col[1], bg = col[2], add = TRUE)
par(op)
}
# }

Run the code above in your browser using DataLab