Choroplethmap {DataVisualizations}R Documentation

Plots the Choropleth Map

Description

A thematic map with areas colored in proportion to the measurement of the statistical variable being displayed on the map. A political map geneated by this function was used in the conference talk of the publication [Thrun/Ultsch, 2018].

Usage

Choroplethmap(Counts, PostalCodes, NumberOfBins = 0,

 Breaks4Intervals, percentiles = c(0.5, 0.95), 
 
 digits = 0, PostalCodesShapes, PlotIt = TRUE,

 DiscreteColors, HighColorContinuous = "red",

 LowColorContinuous = "deepskyblue1", NAcolor = "grey",

 ReferenceMap = FALSE, main = "Political Map of Germany",

 legend = "Range of values", Silent = TRUE)

Arguments

Counts

vector [1:m], statistical variable being displayed

PostalCodes

vector[1:n], currently german postal codes (zip codes), if PostalCodesShapes is not changed manually, does not need to be unique

NumberOfBins

Default: 1; 1 or below continously changes the color as defined by the package choroplethr. A Number between 2 and 9 sets equally sized bins. Higher numbers are not allowed

Breaks4Intervals

If NumberOfBins>1 you can set here the intervals of the bins manually

percentiles

If NumberOfBins>1 and Breaks4Intervals not set, then the percentiles of min and max bin can be set here. See also quantile.

digits

number of digits for round

PostalCodesShapes

Specially prepared shape file with postal codes and geographic boundaries. If you set this object, then you can use non german zip codes. You can see the required structure in map.df, github trulia choroplethr blob master r chloropleth. The German PostalCodesShapes can be downloaded from https://github.com/Mthrun/DataVisualizations/tree/master/data.

PlotIt

Either Plot the map directly or change the object manually before plotting it

DiscreteColors

Set the discrete colors manually if NumberOfBins>1, else it is ignored

HighColorContinuous

if NumberOfBins<=1: color of highest continuous value, else it is ignored

LowColorContinuous

if NumberOfBins<=1: color of lowest continuous value, else it is ignored

NAcolor

Color of NA values in the map (postal codes without any counts)

ReferenceMap

TRUE: With Google map, FALSE: without Google map

main

title of plot

legend

title of legend

Silent

TRUE: disable warnings of choroplethr package FALSE: enable warnings of choroplethr package

Details

This wrapper for the choroplethr enables to visualize a political map easily in the case of german zip codes based on given counts and postal codes. Other postal codes are in principle usable.

Value

List of

chorR6obj

An R6 object of the package choroplethr

DataFrame

Transformed PostalCodes and Counts in a way that they can be used in the package choroplethr.

Note

You could read https://www.r-bloggers.com/2016/05/case-study-mapping-german-zip-codes-in-r/, if you want to change the map (PostalCodesShapes shape object).

Author(s)

Michael Thrun

References

[Thrun/Ultsch, 2018] Thrun, M. C., & Ultsch, A. : Effects of the payout system of income taxes to municipalities in Germany, in Papiez, M. & Smiech,, S. (eds.), Proc. 12th Professor Aleksander Zelias International Conference on Modelling and Forecasting of Socio-Economic Phenomena, pp. 533-542, Cracow: Foundation of the Cracow University of Economics, Cracow, Poland, 2018.

See Also

Google choroplethr package.

Examples


#If you download the package from CRAN
## Not run: 
# 1. Step: Downlaod the shape file from the website 
# https://github.com/Mthrun/DataVisualizations/blob/master/data/GermanPostalCodesShapes.rda
# 2. Step: load it from the local path od the downloaded file with
load(file='GermanPostalCodesShapes.rda')

## End(Not run)

# If you download the package from GitHub, you can omit the two steps above.
# Then, do not use the 'PostalCodesShapes' input parameter

#Many postal codes are required to see a structure
#Exemplary two postal codes in the upper left corner of the map

## Not run: 
out=Choroplethmap(c(4,8,5,4),

c('49838', '26817', '49838', '26817'),

NumberOfBins=2,PlotIt=FALSE,
 PostalCodesShapes=GermanPostalCodesShapes)

out$chorR6obj$render()

## End(Not run)
#bins are only presented in the map if the have values within
## Not run: 
out=Choroplethmap(c(4,8,5,4),c('49838', '26817',

 '49838', '26817'),NumberOfBins=5,
 
 Breaks4Intervals=c(1,2,3,5,10),PlotIt=FALSE,
 PostalCodesShapes=GermanPostalCodesShapes)


out$chorR6obj$render()

## End(Not run)
# Result of [Thrun/Ultsch, 2018]
# Slightly misuse the function for visualizing a political map 
# resulting out of a clustering

## Not run: 
data('ChoroplethPostalCodesAndAGS_Germany')
res=Choroplethmap(as.numeric(ChoroplethPostalCodesAndAGS_Germany$Cls)+1,

ChoroplethPostalCodesAndAGS_Germany$PLZ,NumberOfBins = 2,

Breaks4Intervals = c(0,1,2,3,4,5,6),digits = 1,ReferenceMap = F,

DiscreteColors = c('white','green','blue','red','magenta'),

main = 'Classification of German Postal Codes based on Income Tax Share and Yield',

legend = 'ITS vs MTY Classification in 2010',NAcolor = 'black',PlotIt=FALSE,
 PostalCodesShapes=GermanPostalCodesShapes)


#takes time to process
res$chorR6obj$render()

## End(Not run)

[Package DataVisualizations version 1.3.2 Index]