I want to create a small web application to visualize election results on a per poll site basis for my city. The result is going to be very similar to what has been done for Berlin here. Hopefully this helps in understanding what I'm going for.

The election raw data on the scale I need is published and I know how to visualize this on the grounds of a shapefile with separate polygons lining out the election districts. My problem is - as you could probably guess - that something like this doesn't already exist.

What actually is published though, is a PDF file lining out the borders of the districts I'm interested in: http://muenster.de/stadt/stadtplanung/pdf/a3_stimmbezirk.pdf

I'm not keen on redrawing the linework myself, so I'm looking for a way to make a shapefile out of this. Luckily, the PDf includes the linework as separate vector objects, I extracted these into a SVG file: https://www.dropbox.com/s/bn7698yrdh5tdqj/a3_stimmbezirk_ungrouped.svg

I already tried converting the SVG to a DXF and importing it into qgis 2.0.1. This actually works, but (as expected) places the vectors in the atlantic ocean and I can't find a way to edit it and fix this.

What can I do now to georeference these vectors with open source tools and finally produce a shapefile?

  • Can you not download OpenStreeMap Shapefiles for Munster? download.geofabrik.de/europe/germany/nordrhein-westfalen/… administrative boundaries are there already georeferenced.
    – Mapperz
    Commented Sep 27, 2013 at 13:44
  • Thanks for commenting, Mapperz! Looks like I could, but it doesn't include current election districts ("Stimmbezirke")... or does it?
    – bfncs
    Commented Sep 27, 2013 at 17:17

2 Answers 2


I stumbled upon your question while trying to do the same thing, here's how I did it:

Software used:

  • Inkscape
  • QGIS 2.2
  • Affine Transformation plugin for QGIS

Extracting vector data from PDF

It's what you have already done, basically just open the PDF in Inkscape, find the shapes you want and remove all backgrounds and surrounding text. Save as .dxf file.

Georeferencing the vector file

To work with the vector file we need to convert it to an ESRI Shapefile with QGIS.

Open QGIS and add the dxf file as a raster layer, select DHDN / Gauss-Kruger zone 3 (EPSG:31467) as the coordinate system. Right click the layer, save as ESRI Shapefile. Open this shapefile as a raster layer and remove the other one.

You now have Münsters Wahlbezirke somewhere at coordinates 0, 0.

To translate (move) and resize the vector into the right place, we need to find out the target coordinates and size. To keep it short, I had another GeoJSON of Wahlbezirke that was georeferenced but not as detailed, so I used that to calculate the following data:

  • Target x,y
  • Size ratio between our just extracted vector and target size (by using xMin,xMax and yMin,yMax (extracted from layer metadata in QGIS) to get the dimensions in x an y direction for both layers, then calculate ratio in x and y direction)

In my case these turn out to be roughly:

target x 3406388
target y 5745290
yratio 118,539696
xratio 118,637678

Enable Edit mode (Pencil icon) on your layer and put these numbers into the Affine Transformation plugin (Menu Vector, Geoprocessing Tools, Affine), select "Whole layer":

Affine Transformation

Click transform, disable edit mode (and save) and you end up with an all yellow layer roughly at your target. I have never figured out how to remove the yellow color, so I remove and re-add the layer for better visibility.

You might end up with a view that looks something like this, where your raster layer is super small (circled in red), zoom in here: QGIS 2.2 Small Scale Raster Layer (Maybe I overlooked a setting here, I'm not sure what causes this behaviour. "Zoom to layer extent" does not help.)

Add a layer that is already georeferenced, you might use an OpenStreetMap layer (via OpenLayers extension), a NRW WMS or similar. Your vector is not at the right position yet, so move it by enabling Edit mode, then use Move Feature(s) tool.

QGIS 2.2 Move Feature

Now we have made a layer of polylines, the last step is to make polygons from these lines. I'm not going to explain that here, read here for more information:

See the result here.

  • Thanks a lot for the detailed answer, I didn't expect to get help on this problem any more and meanwhile put the project on hold. I'm still not finished with replicating your steps but this looks like just what I need. I'm looking forward to finally get it done thanks to your help.
    – bfncs
    Commented Apr 13, 2014 at 18:10
  • Editing with QGIS can be tedious and is not quite intuitive (as you can see with the zoom behaviour/bug? and other things...), the result is online at Github for you free to use (link at the end of the post). I haven't gone around to convert the resulting polylines to polygons yet, will do that some time later. Edit: Just saw that you need the other map with 172 districts, I have only converted the 33 districts map.. sorry :D
    – chrki
    Commented Apr 14, 2014 at 9:18

Here is another workflow, using ogr2ogr with GCP points:

  1. Extract the lines as svg (as above)
  2. load into inkscape and save as dxf
  3. Load into QGIS, with EPSG:31467 as CRS
  4. Read a couple of coordinates from significant edges of the surrounding city border
  5. Open OSM editor JOSM and download the relation 62591 of the city border
  6. Save that as GPX
  7. Load the border into a new QGIS session, set project CRS to EPSG:31467
  8. Read the coordinates for the same points as above
  9. create the following batch file for GDAL:
ogr2ogr -a_srs EPSG:31467 -gcp 66.2423 264.3829 3397709. 5756806. -gcp 227.530 17.636 3404474. 5746477. -gcp 443.61 153.42 3413517. 5752162. -gcp 456.24 421.97 3414043. 5763404. -gcp 294.56 552.56 3407296. 5768889. stimmbezirke.shp stimmbezirke.dxf

Run the batch and load the resulting shapefile into QGIS:

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.