I have a shapefile representing the US freight highway network available from Oak Ridge National Lab. I'm trying to prepare this as a .xml
network for processing with MATSim. The output structure is very simple, something like
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE network SYSTEM "http://www.matsim.org/files/dtd/network_v1.dtd">
<network name="VISUM export national network 2007-11-28">
<!-- ====================================================================== -->
<nodes>
<node id="1000" x="730065.3125" y="220415.9531" type="2" origid="1000" />
<node id="1001" x="731010.5" y="220146.2969" type="2" origid="1001" />
.....
</nodes>
<!-- ====================================================================== -->
<links capperiod="01:00:00" effectivecellsize="7.5" effectivelanewidth="3.75">
<link id="100365" from="226" to="227" length="921.0" freespeed="33.3333333333333" capacity="5600.0" permlanes="2.0" oneway="1" modes="car" origid="183" type="10" />
...
</links>
<!-- ====================================================================== -->
</network>
Most users of MATSim pull data from OpenStreetMap using osmosis
, but I have to use this network for a variety of reasons.
I have seen lots of suggestions in different places as to what I might try. Some of these include:
v.net
in GRASSshp2pgsql
suggested by pgRouting tutorial- manually with pgRouting, though this advice may be outdated?
- writing code through the
sp
andrgdal
libraries in R to build a node and link structure. - find someone with a TransCAD license to export the network ORNL provides along with the shapefile, though I don't know TransCAD exports to
.xml
.
It seems that with options 1 - 3, I'll then have to figure out a way to write the .xml
from the database. Option 4 seems difficult, but mainly in terms of my time. I'm happy to learn something new, but I don't want to invest a day towards option 1 only to find that option 3 would have been better.
Or is there a simpler way?
Post-script:
Someone asked the MATSim developers if they had a tool to do the shp -> xml
conversion, but the answer was that shapefiles are too wild to build one.