NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

7
1

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
9.5k2588128
accept rate: 14%

edited 10 Dec '16, 14:27

SK53's gravatar image

SK53 ♦
28.1k48268433

For an updated version of this question relevant to QGIS versions 2.10 upwards see https://help.openstreetmap.org/questions/52409/how-can-i-adding-osm-tiles-as-a-background-layer-in-qgis-21x-and-3x

(10 Dec '16, 14:27) SK53 ♦

The question has been closed for the following reason "Problem is not reproducible or outdated. Answers refer to many out-of-date QGIS versions, and may not be directly applicable in current versions." by SK53 15 Dec '14, 15:29


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.

<GDAL_WMS>
  <Service name="TMS">
  <ServerUrl>http://tile.openstreetmap.org/${z}/${x}/${y}.png</ServerUrl>
  </Service>
  <DataWindow>
    <UpperLeftX>-20037508.34</UpperLeftX>
    <UpperLeftY>20037508.34</UpperLeftY>
    <LowerRightX>20037508.34</LowerRightX>
    <LowerRightY>-20037508.34</LowerRightY>
    <TileLevel>18</TileLevel>
    <TileCountX>1</TileCountX>
    <TileCountY>1</TileCountY>
    <YOrigin>top</YOrigin>
  </DataWindow>
  <Projection>EPSG:900913</Projection>
  <BlockSizeX>256</BlockSizeX>
  <BlockSizeY>256</BlockSizeY>
  <BandsCount>3</BandsCount>
  <Cache />
</GDAL_WMS>

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.

permanent link

answered 09 Sep '12, 01:59

Harry%20Wood's gravatar image

Harry Wood
9.5k2588128
accept rate: 14%

edited 09 Sep '12, 04:30

I like the second approach. How can we modify the XML parameters to increase the quality / precision of the image? Anyone is familiar with this format?

(20 Feb '15, 13:33) antonind

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)

into

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.

permanent link

answered 21 Jul '10, 16:36

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

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

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/ .

permanent link

answered 08 Mar '13, 10:43

gormo's gravatar image

gormo
2.9k32660
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.

permanent link

answered 27 Feb '14, 16:13

smsm1's gravatar image

smsm1
16647
accept rate: 0%

1

For me using QGIS 2.4, note that for step 4 the OpenLayers Plugin appears under the Web menu:

Web -> OpenLayers plugin -> Choose your map

(09 Dec '14, 02:03) robbieonsea

Note that QGIS is now at 2.6. The means of adding the OpenLayers plugin (and indeed whether it works or not) has changed significantly over various point releases of QGIS (from 1.4 onwards). I would suggest closing this question, simply because so many of the up-voted answers are out of date, and even newer answers refer to releases which have already been superseded a couple of times.

(09 Dec '14, 12:09) SK53 ♦

I've no idea why you closed the question - it's still a valid question, even today. I'd like to see the best answer nowadays, but instead google leads me here and there's no way for people to improve the situation with new answers.

(07 Oct '16, 17:36) Andy Allan

@Andy Allan: by all means ask the question again and then we can start with answers relevant to QGIS 2.1x and 3.0. I closed the question at QGIS 2.6 when most of the information was already considerably outdated. It is much more so now.

(08 Oct '16, 10:50) SK53 ♦

Follow this question

By Email:

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

By RSS:

Answers

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

Question tags:

×287
×67

question asked: 21 Jul '10, 15:43

question was seen: 82,091 times

last updated: 10 Dec '16, 14:28

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum