poniedziałek, 6 lutego 2012

GIS -> Shapefile -> Visum (Transport Network), known issues + snippet for common error

This post summaries problems, that transport modelers experience while importing GIS data as transport network. It contains solutions for known issues, and free python script snippet to solve one particular problem with *.shp import.

We all wish that import of GIS data-base would be as seamless as it seems. However, anyone who has ever imported any GIS transport network into transport modeling software knows, that geographers store data in a way that transport modelers don't. That's why when we import GIS data into transport modeling software, it's in most cases useless. In some cases it's even better to draw network from a scratch, then adjusting imported network.


Among known issues we have:
  1. T junctions without connection (case where dead-end node touches link, but the main link goes "over" T-junction). This issue can be handled (at least in Visum), by means of python script and embedded function (GetNearestLink) - see ready to use code down the page.
  2. Crossing links without node (when two links actually cross,but there's no node to connect them). I found a way to overcome it by means of external libraries, and it works fine for me, however for commercial usage its calculating time is unacceptable. I'll try to shorten the calculations by employing additional conditions.PS. What you need to double check in this case is whether this situation is not a bridge/viaduct – for many external databases you have extra parameter for bridges/viaducts and you can easily filter the data.
  3. Overlapping nodes, and
  4. Almost overlapping nodes (when two dead-end nodes should be a junction,and are either atop of each other, either very close to each other).Two cases above are similar, as you need to  check distance between each pair of nodes, and if its below snap radius, just merge the nodes.
  5. One-way roads/Unblocked turns.Unhandled exception. Even if database provides info on “being one-way”, you still need additional info on what is actual direction. So from my point of view it remains the main unsolved issue when importing GIS, and I struggle with this. The best example for this would be such a junction imported from GIS:
  6. Special case for roundabout. This is really pain in the neck, as you really have not much to do but scream when you see such a case in Visum:
There is a way to handle this issue, however its not straightforward.

Python code for TJunction issue (full code available here , python sythax version available here ):

def TJuction_Error_Handle():
radius=0.1 #specify your snap radius here - in KM
Nodes=Visum.Net.Nodes.GetMultipleAttributes(["NumLinks","No","XCoord","YCoord"])
leng=len(Nodes)
for Node in Nodes:
if Node[0]==1:
Visum.Filters.InitAll()
LinkFilter = Visum.Filters.LinkFilter()
LinkFilter.AddCondition("OP_NONE", False, "FromNodeNo",9,Node[1])
LinkFilter.AddCondition("OP_OR", False, "ToNodeNo",9,Node[1])
LinkFilter.Complement= True
LinkFilter.UseFilter = True
Result=Visum.Net.GetNearestLink(Node[2],Node[3],radius,True)
if Result[0]!=None:
try:
Result[0].SplitViaNode(Node[1])
except:
print Result[0].AttValue("FromNodeNo"),Result[0].AttValue("ToNodeNo"),Node[1]
del Nodes
Visum.Filters.InitAll()

TJuction_Error_Handle()



PS2. For more info check out my website, where full product will be available soon, or simply contact me at info@intelligent-infrastructure.eu

PS3. All cases are from my hometown – Gliwice, Poland. First from surroundings of my high school, others from place where I grown up. My parents see the motorway junction from their windows, and they dislike it a lot 


Brak komentarzy:

Prześlij komentarz