Open Street Map into QGIS.



From Open Street Map. CC BY SA 2.0 license.


Getting and using Open Street Maps in QGIS. 
Some of you have asked if there was possible to get maps into QGIS. Besides inputing files from other maps services, the Open Street Maps database is a good source for maps, even if sometimes they may be incomplete. Open Street Maps is a collaborative project to create a free editable map of the world, with a database available through the Creative Commons Attribution-ShareAlike 2.0 license . It is under development, so not all areas are covered with the same amount of detail, but many parts of Europe are quite reliable, and you can even get data from other areas in the world. The best thing is that it is free and that all material is provided with a very liberal license (CC BY-SA 2.0). You can also download images of maps, etc (Google Maps seem to have a much more restrictive license, check point 10.1.3).

There are two ways we have found to get the data into QGIS:
A. The easy one, but limited data:
1-Download shape files of Open Street Maps from cloud mate ( http://downloads.cloudmade.com/europe/northern_europe/sweden#downloads_breadcrumbs). You can download many parts of Sweden (Stockholm among others), the whole Sweden, and many other parts of the world (http://downloads.cloudmade.com) so this may be useful for future projects. Remember to download the files that are called shapefiles, like this one for Stockholm http://downloads.cloudmade.com/europe/northern_europe/sweden/stockholm/stockholm.shapefiles.zip 

2- Unzip them, and you can open them in QGIS (either by clicking the files with ".shp" extension or directly from QGIS, with "Layer > New > New Shapefile Layer" in the menu bar, for example). They will come up distorted, because of the coordinate system of the file. If you wonder what the coordinate system is, and how important is the history of representation, check this http://en.wikipedia.org/wiki/Map_projection).

3- You can change the coordinate system to any other you want, for example "Google Mercator", which is the same that Google Maps uses. You can do this by going to "Settings > Project Properties" and selecting the "Coordinate Reference System (CRS)" tab. There "Google Mercator" is under "Projected Coordinate Systems > Mercator > Google Mercator". Check also the box that says "Enable 'on the fly' CRS transformation", and press OK.

That was that.
You can go now and "Open Attribute Table" on the layer (by right clicking on it) and select data according to the table. As you can see the amount of data is limited, though substantial (if you include all the shapefiles), and it will allow you to match any data with the map of Stockholm.


B The proper way, though complicated.
For having access to all Open Street MAp information you will need to install a database in your computer, that you will access through QGIS. This involves installing some software and using the command line. I had a bit of trouble doing this, but I finally managed. Here is a tutorial for MAC:

We had problems installing PostGIS (if you try to create a database as explained in the tutorial  and "template_postgis" does not show as an option in "Template" , you have the same problem). To fix the problem, You can try to find where the installation zip for PostGIS is in your computer, or download it from here:

and run it. Then follow the steps as indicated in the rest of the tutorial (download osm2pgsql … etc). You also have to enable to save your password when you start the server in pgAd­min III.
You can fins another tutorial with even more advanced style editing explanations here.