Lets talk about QGIS for a little bit before we go ahead and install it on our systems. QGIS is an open source GIS package that is under the GNU public license. It offers enough functionality for someone with a ArcInfo Student License (myself) to want to explore. The usage of QGIS in day to day tasks has me spending less time scratching my head about why something has crashed (ArcMap anyone?) nor am I sitting here waiting for hours on end while the geoprocessing occurs (on and on and on), and ultimately failing to complete. OK ArcMap isn’t so bad! I just love the idea of a community driven GIS project. Even more-so, I love the fact that I can run it on my Macbook Pro without having to load MS Windows. It is at a point in its life where it has matured and is ready to be used in production. With its vast support for almost every filetype (vector or raster), as well as functionality with PostGIS and other databases, it is definitely a universal GIS. Put it this way, if this is your first time using QGIS, you will be adding just another tool to your geospatial arsenal!
Installing QGIS and its dependencies
The QGIS dependencies and the QGIS installer are located on the KyngChaos Wiki.
- navigate to http://www.kyngchaos.com/software/qgis
- download the ‘GDAL Complete 1.8 framework package’ to your ‘/Desktop/osm_tutorial/downloads’ folder
- download the appropriate ‘GSL framework’ to your ‘/Desktop/osm_tutorial/downloads’ folder
- download the appropriate ‘QGIS 1.7.x.x’ build to your ‘/Desktop/osm_tutorial/downloads’ folder
- proceed through the installations of GDAL and GSL before QGIS. Make sure to accept all the default configurations/options.
- QGIS installation is also straight forward, install this after GDAL and GSL
Querying PostGIS inside QGIS
Lets launch QGIS for the first time and query our PostgreSQL/PostGIS database and load some OpenStreetMap data.
- launch QGIS from the applications folder
- ‘file > save project as’ and save the project before we get started and forget to!! Name it something relavent and place it in the ‘/Desktop/osm_tutorial/data’ folder
- the toolbar at the top of the application window holds the tools that allow us to add new data to our map
- by hovering over the icons we can locate the “Add PostGIS Layer” tool. Select this tool to open the Add PostGIS Tables dialogue
- select ‘new’ to add our PostGIS database
- configure your new PostGIS layer as so (remember that the PostGIS layer uses your PostgreSQL configured username and password):
If this works you will be able to connect to your OpenStreetMap PostGIS layer and you will get the following screen
I will show you how to add some data using the query builder. All that you will need to do is get a grasp of the query builder syntax and the OSM tables so you can build your own custom queries and add OSM data to your projects at your hearts content.
- select the first row, ‘public|planet_osm_line|LINESTRING|way’
- select ‘Build Query’
- using the interactive query builder, replicate the following query syntax:
*Tip* select ‘all’ in the ‘Values’ column to see all the available headings
- choose ‘OK’
- select ‘Add’
The data will be queried from your PostgreSQL/PostGIS database and added to your map. If you have followed the tutorial using the Ontario extract you should have something that looks similar to this:
That is it! You are now ready to start using OSM data in your GIS. Note that you can export to shapefile in QGIS so that you can take the data and move it across computers and open it up in other GIS applications (*cough* ArcMap *cough*). Remember to save often incase QGIS crashes. I would hate to have lost some lengthy queries because of a crash… sometimes trying to remember exactly what I included in a query is the hardest part of the project I am working on!
If you have enjoyed this tutorial or if it has helped you to some extent please share your experience below!
Any suggestions or recommendations? I would love to hear from you as well.
Cheers!
[…] Spatial Analysis Mapping with Michael Markieta Skip to content HomePortfolioAbout Me ← Site currently under construction! Using OpenStreetMap Data — P.2 → […]
Great tutorial! I’ve done a bit with Django/GeoDjango/PostGIS and just recently started looking into OpenStreetMap as a source of data and an alternative to Google Maps. My goal today was to get some data in from Open Street Map and see it show up. Following this tutorial helped me do that. The intro to QGIS was a bonus.
Note: The only issue I ran into was that I had an old version of Postgres installed and it took me a bit to figure out that the new version auto-installed on port 5433. Probably not a common problem.
Hi Matt,
Thanks for browsing! I hadn’t thought of the outliers such as yourself which may have had a previous installation of PostgreSQL! Good note on that.
Also, I would like to add that this tutorial will be making its way to the NACIS web-based Cartographic Perspectives journal. It is currently being translated into a more concise and authoritative version. It will also include an extra PostGIS query section which will expand upon how spatial databases empower the GIS user for dissecting large amounts of spatial data.