Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I visualize zip code data of Germany?

Tags:

python

maps

I have a count for each German zip code (e.g. something like this) and I would like to visualize it.

For simplicity, lets say my data looks like this:

data = {'80337': 3, '76131': 36, '86462': 24}  # all others: 0

Now I would like to create a heat map.

I've seen pyGeoDb which looks as if it could fit my need, but I don't know how to use it. And it also seems not to work with Python 3.

like image 956
Martin Thoma Avatar asked Sep 13 '25 10:09

Martin Thoma


2 Answers

I use Google Fusion Tables for a lot of things like this. It does geocoding for free, and heatmaps is one of its basic functions. Easy to embed on webpages, or dig into more deeply with custom JS if needed...

UPDATE Google killed off Fusion tables at some point, but their JS API has a heatmap layer that is pretty straightforward to use. https://developers.google.com/maps/documentation/javascript/heatmaplayer

Although you would need to geocode the zip codes.

like image 76
Adrian Cotter Avatar answered Sep 16 '25 01:09

Adrian Cotter


I have the same problem and I got pyGeoDb working with python3, yet I have to use a workaround (Ubuntu 17.10):

  1. make sure pycairo is installed
  2. download the code from github (https://github.com/mdornseif/pyGeoDb)
  3. create a new folder
  4. copy or move all the files from the folders 'pygeodb', 'tools' and 'data' into your new folder
  5. make the following alterations:

    • in 'draw_german_borders.py', 'draw_germany_plz.py': change 'import pygeodb' to 'import pygeodb_core as pygeodb'
    • in 'plz2python.py' and 'plz2python2013.py' change 'import pygeodb.plzdata' to 'import plzdata'
    • 'plz_draw': rename to 'plz_draw.py', change 'pygeodb.voronoi' to 'voronoi', change 'import pygeodb' to 'import pygeodd as pygeodb' as well as 'pygeodb.borderdata' to 'borderdata'
  6. open a terminal

  7. change 'python ./plz_draw [...]' to 'python plz_draw.py [...]' and keep the rest of the arguments

At least for me it works fine and the maps are created without errors. The only drawback I encountered is that it takes some time and the resulting *.pdf is quite large (at least several 100 megs)

There probably is a more elegant way of doing this, yet for me this is sufficient and working.

Have fun!

like image 43
Lizzie Avatar answered Sep 16 '25 01:09

Lizzie