Choropleth map of Austria in R: Visualizing Regional Data
Choropleth maps are powerful tools for visualizing spatial patterns and regional data. In this quick tutoril, we will explore how to create a choropleth map of Austria using R.
To begin, we will download the necessary shapefile and unzip it using the code below. This will give us access to the administrative boundaries of Austria.
download.file(
'https://biogeo.ucdavis.edu/data/diva/adm/AUT_adm.zip',
'AUT_adm.zip')
unzip('AUT_adm.zip')
Next, we’ll read the shapefile into R using the sf package and assign it to the variable `adm1`. This dataset contains information about the different states in Austria.
adm1 <- sf::st_read('AUT_adm1.shp')
To create the choropleth map, we’ll utilize the ggplot2
package. The geom_sf()
function will help us plot the polygons from the adm1
dataset, and we’ll map the NAME_1
variable to the fill aesthetic to represent the state names. Using the scale_fill_viridis_d()
function, we can choose a suitable color palette to represent the data.
ggplot() +
geom_sf(data = adm1, aes(fill = NAME_1)) +
scale_fill_viridis_d() +
labs(title = "Choropleth Map of Austria", fill = "State") +
theme_minimal()