Reading OBS PBF files using C#

Hello

I downloaded a .osm.pbf file at http://download.geofabrik.de/europe.html. I need to convert the data (streets etc) to Graphs so I can calculate routes. I believe these files already work with Nodes but I have trouble reading the data.

I tried using http://www.osmsharp.com/ but I don’t really understand the software. Can someone give me links to a proper library or give me a few tips in how to access the data from the OSM. Some pseudo / example code is fine aswell.

I’m new to openstreetmaps and this kind of parsing, so I’m sorry if this is a rookie question.

If you have questions please do tell!

Thanks!

I was also totally confused by osmsharp.com - as I recall, there were conflicting requirements in which external libraries to add to a project.

To solve your problem, first consider converting to XML. Osmosis https://wiki.openstreetmap.org/wiki/Osmosis is the best tool for this: during the conversion to XML, you can apply some simple filters and further select a smaller area if needed.

If you plan to do a lot of future work with a large amount of data and need some simpler code to read PBF file format, look at the source code of OSM2MSSql - https://osm2mssql.codeplex.com/ . In the source folder there is osm2mssql\osm2mssql.Importer\OsmReader\ that can read PBF files. It may not have been reviewed as rigorously osmsharp, but I was able to use it in a small project.

Thank you, i’ll definitely check it out!
I’ll update this thread if I found a solution.

also see https://wiki.openstreetmap.org/wiki/Frameworks