Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to extract/filter in all Way elements within a specific region tagged as 'highway' from an OSM file. I am currently thinking of using a Python library called osmread (by A Dezhin) that I stumbled upon online. It's pretty straightforward. Here's an example usage that I got from his repository.

from osmread import parse_file, Way

highway_count = 0
for entity in parse_file('foo.osm.bz2'):
if isinstance(entity, Way) and 'highway' in entity.tags:
    highway_count += 1

print "%d highways found" % highway_count

This is good enough, but I was wondering if qGIS also has a similar function that allows users to filter elements (Node, Way, Relation) given a specific set of criteria. I would prefer to use qGIS for the 'instant' visualization.

In the end, I hope to build a road network and conduct some analysis.

Thanks, all, in advance.

share|improve this question

2 Answers 2

QGIS comes with an OSM plugin which can open .osm files or download smaller regions directly from the web. The result is immediately visualized. Large .osm files will take long to parse. Tags will be written to the attribute table where you can use the usual QGIS query building tools to filter features.

Note that the OSM plugin in QGIS 1.8 is far from perfect and will be replaced by a new version in 2.0 - but it should do the trick.

Another thing worth noting is that the OSM street network is not routable by default since street network edges are not necessarily split at each street intersection. Some serious preprocessing is needed before standard routing algorithms can be applied. See How to make routable OSM map for pointers.

share|improve this answer
    
Thank you for this. Yes, I have already installed the OSM plugin. I just noticed though that the attribute table has very limited columns for tags. Is this correct? For example, lat and lon information are not there. Anyway, I think I have found the information that I have been wanting to extract under Vector > Analysis Tools > Line intersections. Unfortunately, I do not know how I can filter the intersections in terms of Highway classifications (e.g. I want to exclude 'residential' highways). Is this even possible to do with the current version of the OSM plugin+QGIS? –  Pythonista Jul 24 '13 at 1:54
    
If you have a follow-up question about filtering intersections, please open a new thread. Try to be as specific as possible about which criteria should be used to select an intersection. –  underdark Jul 24 '13 at 13:47

I figured it out. Since I am new to qGIS, I just found out that there's a Query Builder. This is what I was looking for.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.