# cost matrix

2347
12
09-12-2010 06:12 PM
New Contributor
Hi there,

I have a network dataset which represents roads and a shapefile with cities ....what I wanna do is to generate a cost matrix that contains the distance between two connected cities in the network. For this case the OD_matrix_solver is not desired because it calculates shortest distances between cities.... all I want is the "link_length" between cities..... I've been looking some scripts but most of them just compute euclidean distances between connected points..the question is how I can do the same but using the real shape.

I imagine that analogously to OD_matrix_solver...first I'd have to snap locations to my road network and next to generate the matrix.

Can anyone give me a little help here???...thanks
Tags (2)
12 Replies
Esri Regular Contributor
Knowing which city is connected to which city is the key. Without it you can not generate the information. As far as I am concerned, the shortest path between two cities gives you the summed up cost of the links making up the path between the cities. So you can simply use OD for that AND if you want one shape that combines all the shapes making the path, use the Closest Facility Solver. It is same as OD but also returns back the true shape of the path that connects two locations. Hint: You can run CF between all cities and export the resulting paths to a new Feature class and then make network dataset from it.

BTW there is also a GP tool in Network Analyst toolset called DissolveNetwork that will remove all possible two valent junctions from a network dataset (by merging adjacent edges). Perhaps that can be used to simplyfy your network. More info here:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Dissolve_Network/00480000000w000000/

Regards,
Jay Sandhu
New Contributor
Hi there,

The code to compute the adjencecy matrix works very good...is there any way to compute the junctions coordinates (X,Y) through this code???

Thanks

Philip
Esri Regular Contributor
You can get the x,y points of the junctions by querying the from/to junctions. For example, you can:

dim pFromPoint as IPoint
set pFromPoint = new Point

and then inside the loop after the QueryJunction call:

pNEFromJunc.QueryPoint pFromPoint

and now you can access the coordinates:

debug.print pFromPoint.X
debug.print pFromPoint.Y

repeat the above for the pNEToJunc

Hope that is what you wanted.
Regards,
Jay Sandhu