Last data update: 2014.03.03

R: A simple choropleth map of Japan
JapanPrefecturesMapR Documentation

A simple choropleth map of Japan

Description

Draw a very simple choropleth map of Japan with prefecture boundaries

Usage

JapanPrefecturesMap(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 SpatialPolygons class.

Details

The function JapanPrefecturesMap 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.

Value

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

Note

For the sake of simple visualization, prefecture boundaries are lacking accuracy; assisted by Quantum GIS (http://www.qgis.org/), the author drew by hand the boundaries omitting minor islands. Therefore, users should not use the map for calculating area or measuring a distance.

Author(s)

Susumu Tanimura aruminat@gmail.com

See Also

cshp in cshapes package, japan in mapdata package.

Examples

if (require(RColorBrewer)) {
  cols <- rev(brewer.pal(8,"Set2"))
}else{
  cols <- gray.colors(8)
}
JapanPrefecturesMap(col = cols, axes = TRUE)

require(foreign)
dat <- read.dbf(system.file("shapes/jpn.dbf", package="Nippon"))
op <- par(bg = "skyblue")
p <- JapanPrefecturesMap(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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Nippon)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Nippon/JapanPrefecturesMap.Rd_%03d_medium.png", width=480, height=480)
> ### Name: JapanPrefecturesMap
> ### Title: A simple choropleth map of Japan
> ### Aliases: JapanPrefecturesMap
> ### Keywords: character Japanese language
> 
> ### ** Examples
> 
> if (require(RColorBrewer)) {
+   cols <- rev(brewer.pal(8,"Set2"))
+ }else{
+   cols <- gray.colors(8)
+ }
Loading required package: RColorBrewer
> JapanPrefecturesMap(col = cols, axes = TRUE)
> 
> require(foreign)
Loading required package: foreign
> dat <- read.dbf(system.file("shapes/jpn.dbf", package="Nippon"))
> op <- par(bg = "skyblue")
> p <- JapanPrefecturesMap(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)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>