Working with Electricity Grid Data from OpenStreetMap

From Enipedia
Jump to: navigation, search


[edit] Importing OpenStreetMap Data into QGIS

A huge amount of data on the power grid is available in OpenStreetMap. We currently filter out everything tagged as "power=*" every night and make files available at

To work with this data, you can use tools such as JOSM or QGIS. ITOMap also provides an online map that allows you to browse the data.

The instructions below show how to work with the file from that directory and view it in QGIS.

First, download and then unzip the file. This will give you a file called GermanyPower.osm, which uses the OSM XML file format.

Then open up QGIS and click on Vector -> OpenStreetMap -> Import topology from XML.

QGIS Menu Vector OpenStreetMap Import topology from XML.png

Find the OSM file, and then you'll see that a SpatialLite DB file will be created once you click OK. Make sure that "Create connection (SpatialLite) after import" is checked.

QGIS OSM Grid OpenStreetMap Import.png

You next need to export the data to tables in a SpatialLite database.

QGIS Menu Vector OpenStreetMap Export topology to SpatialLite.png

You now need to create a layer that you can work with. If you're interested in power lines, then you need to check the Export type of "Polylines (open ways)". Polygons and points will likely get you substations and power stations. Points will also contain pylons for power lines and transformers. Check the tags that you would like to include in the SpatialLite database. Exports will need to be done separately for points, polylines an polygons

Export OpenStreetMap topology to SpatialLite.png

Once you do this, the data should be visible in QGIS:

QGIS German Grid Imported from OSM.png

You can then use QGIS to run all sorts of GIS functions such as calculating line lengths.

[edit] Viewing ITOMap (OpenStreetMap) Electricity Layers in JOSM

ITOMap is a great service that visualizes many types of the data in OpenStreetMap that are not shown in the default view. Two maps of interest are the ones on Electricity Generation and Electricity Distribution. Much of the data in these maps are traced from high resolution Bing imagery, with gaps in the data often occur at the boundaries of high res imagery. If you're interested in improving the data, it's useful to be able to overlay the ITOMap map tiles on top of Bing imagery in order to see if the imagery has been updated.

To set this up, first click on Imagery -> Imagery preferences. When the window below pops up, tick on "+ TMS" on the right side of the bottom list.


You next want to add the URL http://t{switch:0,1,2,3}{zoom}/{x}/{y}.png to the top text box. Also make sure to specify a name for the layer such as "ITOMap Electricity Generation"


You can now load the layer using Imagery -> ITOMap Electricity Generation


You should see a view like this:


You can then turn on the imagery for Bing. Make sure to move the Bing imagery layer to the bottom of the stack so that the ITOMap layer is on top.


To do the same for the ITOMap for Electricity Distribution, repeat the instructions above with the URL http://t{switch:0,1,2,3}{zoom}/{x}/{y}.png

[edit] Determining the URLs to use for other Tile Map Service map layers

In order to do the same for other map services, you basically need to look at the network traffic between the browser and the website. It's simple to do this in Chrome using "Tools -> Javascript Console" or "More tools -> Javascript Console".


Once this opens, make sure to click on the network tab, and then move the map are a little. You'll see that this generates new requests to the server, which then sends back the map tiles for the area that you requested.


Right click on one of the tiles and then select "Copy Link Address". If you paste this into notepad, you'll see something like From this URL, you can reconstruct the URL pattern to use. There are a few parts to pay attention to:

  • t0 - This indicates that they retrieve the map tiles from several servers in order to distribute the load. If you keep moving the map around and watch the network traffic, you'll see that there are also t1, t2 and t3 servers. In creating the URL for the TMS map layer, then use t{switch:0,1,2,3} so it will randomly pick a different server and help keep their map responsive for other users. This may not be present with some TMS layers.
  • 106 - This refers to the particular ITOMap that you're looking at. This may not be present with other TMS layers
  • 5/26/14 - zoom level, x value, y value for the particular tile. This is quite common (standard?) with many TMS layers. This means that tile 5/27/14 refers to the tile just to the right of 5/26/14.

Based on this, you can see the original URL below, with the parts to modify highlighted:

  • Original URL:
  • URL for TMS: http://t{switch:0,1,2,3}{zoom}/{x}/{y}.png
Personal tools