This repo helps you make your own choropleth map in R using <100 lines of code. My R script helps you create a pretty animated choropleth map of aerial distance from the nearest motorway for every German municipality. I downloaded the shapefile of LAU 2019 from the Eurostat website (https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/lau) and extracted German municipalities in QGIS.
I calculated the distance from every municipality to the closest motorway as follows. First, I downloaded the latest data on roads from Open Street Maps Geofabrik (https://download.geofabrik.de/europe/germany.html). Then I merged the multiple road shapefiles in QGIS, filtered motorways and turned lines into points (Extract vertices algorithm in QGIS). Next, I calculated the centroids for every municipality using Centroids function from Geometry Tools in QGIS. Then, I computed the aerial distance from every centroid to motorway point using Distance to the Nearest Hub (point) algorithm in QGIS. The resulting values are in kilometers. Finally, I exported the data in the form of a shapefile (labeled "germany_lau" in the Data section of this repo). The script is located in the R folder of this repo.