Skip to content

faq 102694928

Billy Charlton edited this page Sep 5, 2018 · 2 revisions

How to convert osm to matsim network file?

by Celeste Manu on 2016-12-23 23:33:55


OSM files come with <nodes> which look ok but what should be <links> are <ways>:

<way id="442276410" visible="true" version="1" changeset="42134383" timestamp="2016-09-13T19:41:14Z" user="piligab_labuildings" uid="4210501">
 <nd ref="4399681358"/>
 <nd ref="4399681348"/>
 <nd ref="4399681347"/>
 <nd ref="4399681181"/>
 <nd ref="4399681180"/>
 <nd ref="4399681163"/>
 <nd ref="4399681162"/>
 <nd ref="4399681120"/>
 <nd ref="4399681117"/>
 <nd ref="4399681201"/>
 <nd ref="4399681200"/>
 <nd ref="4399681280"/>
 <nd ref="4399681281"/>
 <nd ref="4399681304"/>
 <nd ref="4399681303"/>
 <nd ref="4399681357"/>
 <nd ref="4399681358"/>
 <tag k="building" v="house"/>
 <tag k="building:units" v="1"/>
 <tag k="ele" v="46.0"/>
 <tag k="height" v="4.5"/>
 <tag k="lacounty:ain" v="4156008024"/>
 <tag k="lacounty:bld_id" v="448474775703"/>
 <tag k="start_date" v="1952"/>
 </way>

and they don't have any of the same properties of proper MATsim links:
 

<links>
 <link id="1" from="1" to="2" length="10000.00" capacity="36000" freespeed="27.78" permlanes="1" />
 </links>

I've seen a bunch of people use OSM files for their networks, but it outputs an error when I try to use an osm file. I get the osm file just from clicking "Export" after manually selecting a small intersection on openstreetmap:
http://www.openstreetmap.org/#map=19/33.87084/-118.37282 


Comments: 2


Re: How to convert osm to matsim network file?

by Johan W. Joubert on 2016-12-24 10:12:15

Hi Celi,

indeed, many of us `use OSM files', but that said, we just use OSM as source, not the *.osm file directly. You need to convert it from the OSM format to a MATSim network. There is a converter in the core:

org.matsim.core.utils.io.OsmNetworkReader

That class helps you to set context-specific variables (optional, if you want to), like how many lanes should a `primary' OSM link have by default. As an example of how I impemented it for the South African case, have a look at

playground.southafrica.utilities.network.ConvertOsmToMatsim

I am not sure if there is another specific MATSim example class... likely, but I just couldn't find it right now.


Re: How to convert osm to matsim network file?

by ehsan vossough on 2017-02-13 21:52:35

Thanks Johan, this version I got from

http://matsim.org/docs/extensions/matsim4urbansim/brussels-network   step3.

 I want to convert Osm to xml(Matsim) format for simulation. Now I realize there is also OsmNetworkReader.OsmXmlParser, which will try. Thanks.

Clone this wiki locally