How can I bring in OpenStreetMap raster maps into QGIS?

QGIS supports WMS layers for raster maps. Are there OpenStreetMap WMS servers? but also, is there any easy support for standard "google format" tile servers (like tile.openstreetmap.org which uses tile URLs matching google's approach)

(Note bringing in OpenStreetMap vector data is, in many ways, more interesting. See How can I use OpenStreetMap data in GIS program? This question is about using raster map layers)

asked 21 Jul '10, 15:43

Harry%20Wood's gravatar image

Harry Wood
accept rate: 14%

edited 22 Jul '10, 15:28

For a list of WMS servers, see the OSM Wiki. Most of these either require a paid subscription, or have limited coverage, a reduced update frequency, or reduced image quality. The reason for that is that operating a WMS server is more expensive in terms of resources used than for example a tile server. There was a time when OSM itself operated a WMS server but that was long ago.

There is a Google plugin for QGIS. You need to have Python support enabled for qgis (package qgis-python installed under Ubuntu), then install the "plugin installer" plugin from the "Plugins/Manage Plugins" menu. Then go to "Plugins/Fetch Python Plugins", enable third party repositories, and you will be able to install a "Google Layers" plugin.

This plugin only works when your project projection is set to EPSG:3785 (or 900913), and it is hard-coded to work with Google static map images. You can change this to work with OSM static maps. Look at the gmaps.py source in ~/.qgis/python/plugins/GoogleLayers after you have installed the plugin and change the lines

url = "http://maps.google.com/staticmap?"
url += "center=%s,%s&zoom=%s&size=%sx%s&sensor=false&format=%s&maptype=%s" % (self.cwgs.y(), self.cwgs.x(), \
   self.zoomlevel, self.tile_width, self.tile_height, self.format, self.maptype)


url = "http://dev.openstreetmap.org/~pafciu17/?module=map&center=%s,%s&zoom=%s&width=%s&height=%s"  % \
   (self.cwgs.x(), self.cwgs.y(), self.zoomlevel, self.tile_width, self.tile_height)

Of course if you're a proper Python programmer you could also extend the plugin to have a data source selection and support OSM in addition to Google, instead of just hardwiring it.


answered 21 Jul '10, 16:36

Frederik%20Ramm's gravatar image

Frederik Ramm
accept rate: 22%

edited 22 Jul '10, 21:05

There is also an OpenLayers plugin that would theoretically do the job. I have never gotten it to work though. http://hub.qgis.org/projects/openlayers/wiki

(10 Nov '11, 18:07) mvexel

Just trying this again in QGIS 1.8.0 . Neither "Google Layers" nor "OpenLayers" seem to be available as plugins nowadays, so it seems this answer no longer works

(09 Sep '12, 02:01) Harry Wood

Correction 'enable third party repositories' no longer exists as an option, but I was able to install OpenLayers plugin by adding a repository URL. Once installed, good news!, it no longer requires the tinkering described here. OpenStreetMap is available as an option on the menu. I've given an updated answer

(09 Sep '12, 13:45) Harry Wood

Two different ways:

1) The easiest way is to install the OpenLayers QGIS plugin. Unfortunately the installation process is a little clumsy since this plug-in is in a different repository.

This should allow you to find and install the OpenLayers plugin

2) The second approach is to set up a GDAL configuration as described in this blog post:

Copy this into an XML file, and then simply open that file as a new raster layer.

  <Service name="TMS">
  <Cache />

This second approach is more flexible e.g. if you wanted to point at a different tile server such as MapQuest Open. Don't forget to display some credits to OpenStreetMap in your outputs. The first approach adds this automatically.

With either approach you should do 'view' menu -> 'zoom actual size'. QGIS then locks onto a good zoom to match the resolution of the tiles.


answered 09 Sep '12, 01:59

Harry%20Wood's gravatar image

Harry Wood
accept rate: 14%

edited 09 Sep '12, 04:30

Note that the answers from 2010 are a bit outdated, the current "best practice" is the OpenLayers Plugin, which is described in this blog post: http://spatialgalaxy.net/2012/01/14/qgis-plugin-of-the-week-openlayers/ .


answered 08 Mar '13, 10:43

gormo's gravatar image

accept rate: 13%

It's much simpler now.

  1. Plugins > Manage and Install Plugins
  2. Install and ensure ticked "OpenLayers Plugin" plugin.
  3. Restart
  4. Plugins > OpenLayers Plugin > Choose your map

A new Map layer is added with the map layer you choose in step 4.

You might need to drag the new OSM layer to the bottom of the layers list, so that the layering is correct.


answered 27 Feb, 16:13

smsm1's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 21 Jul '10, 15:43

Seen: 22,898 times

Last updated: 27 Feb, 16:57

powered by OSQA