This folder contains the code I have used to generate maps that have the different hospitals etc in it.
My own purpose is to visualize where the labtests are performed and requisitioned. However, it might be of use to other people as well.
The readme was written in Quarto, but converted into md for the sake of github. Pre-plotting steps are perfomed in python, plotting in R.
Important resources are:
- Medcom - Information on all medical providers
- Henvisningstabel:
https://medcom.dk/projekter/pakkehenvisninger/henvisningstabellen/
- Information on the service provided (but has some ydernumre)
- Henvisningstabel:
https://medcom.dk/projekter/pakkehenvisninger/henvisningstabellen/
- SHAK-codes - Sygehus-afdelingsklassifikation
- SOR-codes - sundhedsvæsnets organisationsregister
- DAWA - geographical information based on addresses
- Used via API to find coordinate / municipality of a given address
All files are saved as geojson - very like json but with a geometry column that contains coordinates that can be plotted. Geopandas also have a lot of tools for working with the geometries.
3 main scripts are there:
- data.py
- Contains the data loading. Loads from the above mentioned webpages.
- coordinates.py
- Adapts the loaded data and makes geojson files that contain stuff for plotting.
- plotting.r
- Code for plotting the geojson in r. This includes code for loading the geojson and converting it to a tibble. This can also be done in python - although the geojsons can be directly loaded and plotted in geopandas / matplotlib.
Some examples of:
- Denmark and administrative divisions.
- Individual level Health institutions
- Aggregated level Health institutions
First of a simple plot of Denmark. The colors are just individual “blobs”.
Then the regions:
The municipalities:
The Postal code:
That was it for administrative division, but more can be downloaded from DAWA if you want to.
First the SHAK codes:
Then the Ydelses codes:
And the SOR-codes:
I only do it for 30 municipalities because the computations are big for matching all shak with all areas - but it can be done on the server if transferred.








