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].
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)
List of
An R6 object of the package choroplethr
Transformed PostalCodes and Counts in a way that they can be used in the package choroplethr
.
vector [1:m], statistical variable being displayed
vector[1:n], currently german postal codes (zip codes), if PostalCodesShapes
is not changed manually, does not need to be unique
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
If NumberOfBins>1 you can set here the intervals of the bins manually
If NumberOfBins>1 and Breaks4Intervals not set, then the percentiles of min and max bin can be set here. See also quantile
.
number of digits for round
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.
Either Plot the map directly or change the object manually before plotting it
Set the discrete colors manually if NumberOfBins>1, else it is ignored
if NumberOfBins<=1: color of highest continuous value, else it is ignored
if NumberOfBins<=1: color of lowest continuous value, else it is ignored
Color of NA values in the map (postal codes without any counts)
TRUE: With Google map, FALSE: without Google map
title of plot
title of legend
TRUE: disable warnings of choroplethr
package
FALSE: enable warnings of choroplethr
package
Michael Thrun
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.
[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.
Google choroplethr
package.
#If you download the package from CRAN
if (FALSE) {
# 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')
}
# 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
if (FALSE) {
out=Choroplethmap(c(4,8,5,4),
c('49838', '26817', '49838', '26817'),
NumberOfBins=2,PlotIt=FALSE,
PostalCodesShapes=GermanPostalCodesShapes)
out$chorR6obj$render()
}
#bins are only presented in the map if the have values within
if (FALSE) {
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()
}
# Result of [Thrun/Ultsch, 2018]
# Slightly misuse the function for visualizing a political map
# resulting out of a clustering
if (FALSE) {
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()
}
Run the code above in your browser using DataLab