(If you cannot use the osm data (for example because you have network data in a different format), see here.)
http://download.geofabrik.de/osm/europe/ and download the switzerland.osm.bz2 file. Unpack it using a bunzip2 utility for your platform.http://wiki.openstreetmap.org/wiki/Osmosis and download the latest stable build. Try running the command line program osmosis and have a look at the available options.osmosis --rx file=switzerland.osm --bounding-box top=47.701 left=8.346 bottom=47.146 right=9.019 completeWays=true --used-node --wx zurich.osm
osmosis --rx file=switzerland.osm --tf accept-ways highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link --used-node --wx switzerland-bigroads.osm
osmosis --rx file=switzerland-bigroads.osm --rx zurich.osm --merge --wx merged-network.osm
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.api.experimental.network.NetworkWriter;
import org.matsim.core.config.Config;
import org.matsim.core.network.algorithms.NetworkCleaner;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.geometry.CoordinateTransformation;
import org.matsim.core.utils.geometry.transformations.TransformationFactory;
import org.matsim.core.utils.io.OsmNetworkReader;
import org.matsim.core.utils.misc.ConfigUtils;
public class CreateNetwork {
public static void main(String[] args) {
String osm = "merged-network.osm";
Config config = ConfigUtils.createConfig();
Scenario sc = ScenarioUtils.createScenario(config);
Network net = sc.getNetwork();
CoordinateTransformation ct =
TransformationFactory.getCoordinateTransformation(
TransformationFactory.WGS84, TransformationFactory.WGS84_UTM33N);
OsmNetworkReader onr = new OsmNetworkReader(net,ct);
onr.parse(osm);
new NetworkCleaner().run(net);
new NetworkWriter(net).write("network.xml");
}
}
If you cannot use the osm data (for example because you have network data in a different format), see here.
| Slides 2.92 MB |