You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2016-11-21 19:50:08

eelcolele
New Member
Registered: 2016-11-21
Posts: 2

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!

Offline

#2 2016-11-22 13:14:09

MikeN
Member
Registered: 2009-09-03
Posts: 328

Re: Reading OBS PBF files using C#

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.

Offline

#3 2016-11-23 20:08:56

eelcolele
New Member
Registered: 2016-11-21
Posts: 2

Re: Reading OBS PBF files using C#

MikeN wrote:

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.

Offline

#4 2016-11-23 21:35:52

stephan75
Member
Registered: 2008-05-28
Posts: 2,918

Re: Reading OBS PBF files using C#

Offline

Board footer

Powered by FluxBB