matsim-org / matsim-code-examples

A repository containing code examples around MATSim
GNU General Public License v3.0
83 stars 180 forks source link

creating network, plans and population #518

Open subrina0013 opened 3 years ago

subrina0013 commented 3 years ago

Dear all I have my data that has around 1 million origin-destinations that I want to simulate. As I am new to Matsim, I am struggling to find ways to do this. Is there any example code snippet that I can use to convert OSM pbf/shapefile to Matsim network? I used Josm to convert an .osm file to matsim network file but it does not have the attributes (origid, type). I saw 'matsim/core/network/NetworkUtils' to create the attributes and relationship but how to use this class? Do I need to use .osm file or after JOSM output?

Also, how to create population and plan files for these 1 million agents with home and work locations? Any suggestion how I can create these files would be very helpful. Can anyone please share how to create a network, plan or population file?

Thank you so much.

RydAlex commented 3 years ago

To generate MATSIM file you can use SUMO tool called netconvert - as they can load .osm/.sumo format and export MATSIM one.

To generate Population it is nice to use PopulationUtils and just create 1 million Persons using regular for loop. There is a lot of those ...Utils class - for example, PlansUtils, RouteUtils etc.

When you will have Population generated, use org.matsim.core.population.ioPopulationWriter to write it to the file.

ConfigUtils will allow you to create a config that can be run by the MatSim simulator.

mrieser commented 3 years ago

Regarding the OSM to Network conversion. There are a few options:

Network network = new SupersonicOsmNetworkReader.Builder()
                  .setCoordinateTransformation(coordinateTransformation)
                  .build()
                  .read("path/to/osm-data.osm.pbf");

It also provides some options to customize the network, see the builder methods. But you need to add the contrib as a Maven dependency to your pom.xml.

but it does not have the attributes (origid, type)

those two attributes are deprecated and thus likely no longer generated by the JOSM plugin.

subrina0013 commented 1 year ago

Dear RydAlex and mrieser, it has been a while since I created the network with pt2matsim. Now, for another project, I need to understand how MATSim assigns speed limit. So, I went back to the network and found strange speeds. For example, this one has freespeed 101 & 6.9. The speeds are in meter/s right? How come the same osm id has different speeds? And isn't 101 look wrong? I checked and this road is unclassified with no speed limit. So, pt2matsim assigns 'tertiary' as type but why it has 101 as speed?

image

mrieser commented 1 year ago

double post, see https://github.com/matsim-org/pt2matsim/issues/196