A Book With Every Postcode In The Netherlands

Download the eBook here (12 MB, 1700+ pages), or continue reading:

When writing postcode-locaties I found out about the Postcode books which were published by PTT Post with the introduction of postcodes in 1977. They contain all postcodes in the Netherlands grouped by place, street name and house numbers. In modern times this can be looked up on the internet and the books are no longer being published, but how fun would it be to be able to browse through an up-to-date digital version.

Privacy

Before we start, let’s talk about privacy regarding this book. It’s simple: the document will not contain any personal data. It merely formats the already public BAG (Basisregistratie Adressen en Gebouwen) data. This is different from a phone book which would contain names and phone numbers of individuals and businesses.

BAG data

Last time we used a dataset from the CBS (Centraal Bureau voor de Statistiek) because it contains the shape data of each postcode. This time we’ll use data from the BAG which is more recent and has information about every building in the Netherlands, including construction date, shape data, and postcode. It is published under a CC-0 license. Bert Hubert has made the conversion tool bagconv and kindly provides the data in CSV format.

The original books also include postcodes of PO boxes. Since the BAG data does not contain these they are simply not included in the generated book.

If we go through all 9,980,998 rows we find 2,427 places:

...
Hellum
Helmond
Helvoirt
Hem
Hemelum
Hemmen
Hempens
Hemrik
Hendrik-Ido-Ambacht
...

The original books organize postcodes like this:

Place > Street name > House number (range) > Postcode

With some grouping and sorting it matches the data in the original book:

{
	"Hendrik-Ido-Ambacht": {
		"Banckertplein": [
			{
				"postcode": "3342TJ",
				"start": 22,
				"end": 52,
				"parity": "EVEN"
			},
			{
				"postcode": "3342TK",
				"start": 54,
				"end": 84,
				"parity": "EVEN"
			},
			...

Designing the layout

The website www.iconenvandepost.nl used to have interesting information about things related to post in the Netherlands but it has been offline for some time. On this archived page some information about the book can be found. The images and PDF download are not archived however.

The dimensions are mentioned: 29 x 20.5 cm. This matches with the book in the photo: 29 cm / 485 px x 340 px = 20.3 cm. Let’s start with that:

\usepackage[
	paperheight=29cm,
	paperwidth=20.5cm,
	top=1cm,
	bottom=1.5cm,
	right=1cm,
	left=1cm,
	heightrounded
]{geometry}

With the BAG data organized in a format similar to the book, it’s time to create the layout. This is easily done using the TeX engine. We can import other .tex files so the data can be written to an intermediate file:

\woonplaats{Aadorp}
\straatnaam{Aadijk}
\entry{8}{14}{EVEN}{7611}{A}{Z}
\straatnaam{Acacialaan}
\entry{2}{48}{EVEN}{7611}{A}{R}
\entry{1}{7}{ONEVEN}{7611}{A}{P}
...

With these custom commands we avoid having to rerun the Python script for every layout change. They are defined like this:

\newcommand{\straatnaam}[1] {
    \subsection*{\scriptsize #1}
}

To make editing the layout faster the script also outputs a .tex file with fewer places. With the TeX package multicol the data can be put in columns, and with imakeidx we can generate an index of the places.

After a bit more tinkering the final version is here. Ten minutes later and the PDF is generated: 17 MB, 1740 pages, 243,821 street names and 473,431 postcodes. Compressing it with Ghostscript brings that down to 12 MB. Splendid!

Download

If you want to scroll through the document (and find out if your PDF viewer freezes), you can download it here. You can find the code to generate your own personal copy in this repo.