Lets talk about QGIS for a lit­tle bit before we go ahead and install it on our sys­tems. QGIS is an open source GIS pack­age that is under the GNU pub­lic license. It offers enough func­tion­al­ity for some­one with a ArcInfo Stu­dent License (myself) to want to explore. The usage of QGIS in day to day tasks has me spend­ing less time scratch­ing my head about why some­thing has crashed (ArcMap any­one?) nor am I sit­ting here wait­ing for hours on end while the geo­pro­cess­ing occurs (on and on and on), and ulti­mately fail­ing to com­plete. OK ArcMap isn’t so bad! I just love the idea of a com­mu­nity dri­ven GIS project. Even more-so, I love the fact that I can run it on my Mac­book Pro with­out hav­ing to load MS Win­dows. It is at a point in its life where it has matured and is ready to be used in pro­duc­tion. With its vast sup­port for almost every file­type (vec­tor or raster), as well as func­tion­al­ity with Post­GIS and other data­bases, it is def­i­nitely a uni­ver­sal GIS. Put it this way, if this is your first time using QGIS, you will be adding just another tool to your geospa­tial arsenal!

Installing QGIS and its dependencies

The QGIS depen­den­cies and the QGIS installer are located on the Kyn­gChaos Wiki.

  • nav­i­gate to http://www.kyngchaos.com/software/qgis
  • down­load the ‘GDAL Com­plete 1.8 frame­work pack­age’ to your ‘/Desktop/osm_tutorial/downloads’ folder
  • down­load the appro­pri­ate ‘GSL frame­work’ to your ‘/Desktop/osm_tutorial/downloads’ folder
  • down­load the appro­pri­ate ‘QGIS 1.7.x.x’ build to your ‘/Desktop/osm_tutorial/downloads’ folder
  • pro­ceed through the instal­la­tions of GDAL and GSL before QGIS. Make sure to accept all the default configurations/options.
  • QGIS instal­la­tion is also straight for­ward, install this after GDAL and GSL

Querying PostGIS inside QGIS

Lets launch QGIS for the first time and query our PostgreSQL/PostGIS data­base and load some Open­StreetMap data.

  • launch QGIS from the appli­ca­tions folder
  • file > save project as’ and save the project before we get started and for­get to!! Name it some­thing relavent and place it in the ‘/Desktop/osm_tutorial/data’ folder
  • the tool­bar at the top of the appli­ca­tion win­dow holds the tools that allow us to add new data to our map
  • by hov­er­ing over the icons we can locate the “Add Post­GIS Layer” tool. Select this tool to open the Add Post­GIS Tables dialogue
  • select ‘new’ to add our Post­GIS database
  • con­fig­ure your new Post­GIS layer as so (remem­ber that the Post­GIS layer uses your Post­greSQL con­fig­ured user­name and password):

If this works you will be able to con­nect to your Open­StreetMap Post­GIS layer and you will get the fol­low­ing 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 syn­tax and the OSM tables so you can build your own cus­tom 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 inter­ac­tive query builder, repli­cate the fol­low­ing query syntax:

*Tip* select ‘all’ in the ‘Val­ues’ col­umn to see all the avail­able headings

  • choose ‘OK
  • select ‘Add’

The data will be queried from your PostgreSQL/PostGIS data­base and added to your map. If you have fol­lowed the tuto­r­ial using the Ontario extract you should have some­thing that looks sim­i­lar to this:

That is it! You are now ready to start using OSM data in your GIS. Note that you can export to shape­file in QGIS so that you can take the data and move it across com­put­ers and open it up in other GIS appli­ca­tions (*cough* ArcMap *cough*). Remem­ber to save often incase QGIS crashes. I would hate to have lost some lengthy queries because of a crash… some­times try­ing to remem­ber exactly what I included in a query is the hard­est part of the project I am work­ing on!

If you have enjoyed this tuto­r­ial or if it has helped you to some extent please share your expe­ri­ence below!

Any sug­ges­tions or rec­om­men­da­tions? I would love to hear from you as well.

Cheers!

  3 Responses to “Using OpenStreetMap Data - P.2”

  1. […] Spa­tial Analy­sis Map­ping with Michael Marki­eta Skip to con­tent Home­Port­fo­lioAbout Me ← Site cur­rently under con­struc­tion! Using Open­StreetMap Data — P.2 → […]

  2. Great tuto­r­ial! I’ve done a bit with Django/GeoDjango/PostGIS and just recently started look­ing into Open­StreetMap as a source of data and an alter­na­tive to Google Maps. My goal today was to get some data in from Open Street Map and see it show up. Fol­low­ing this tuto­r­ial helped me do that. The intro to QGIS was a bonus.

    Note: The only issue I ran into was that I had an old ver­sion of Post­gres installed and it took me a bit to fig­ure out that the new ver­sion auto-installed on port 5433. Prob­a­bly not a com­mon problem.

    • Hi Matt,

      Thanks for brows­ing! I hadn’t thought of the out­liers such as your­self which may have had a pre­vi­ous instal­la­tion of Post­greSQL! Good note on that.

      Also, I would like to add that this tuto­r­ial will be mak­ing its way to the NACIS web-based Car­to­graphic Per­spec­tives jour­nal. It is cur­rently being trans­lated into a more con­cise and author­i­ta­tive ver­sion. It will also include an extra Post­GIS query sec­tion which will expand upon how spa­tial data­bases empower the GIS user for dis­sect­ing large amounts of spa­tial data.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>