Tuesday, September 16, 2008
Programmatically tracing a network in ArcGIS
Recently I was tasked with tracing a water network, and after studying a previous programmer's work on the subject, I realized the solution is just a modified tree algorithm that is largely language independent.
The trick is a recursive function that continues to call itself until it has gone down the totality of a single path. When it can't keep going - because it reaches the end of the line or because you convince the program it is the end of the line - it hops back one function call and tries to take an unvisited path. If it finds one, it repeats the whole process.
The ArcObjects API contains the extensions for Network and Utility Network tools, but as far as I can tell,those are mostly for listening for trace events rather than starting your own. Since a network like that is just a modified topology (it inherits from ESRI's topology object), you can use ITopology to create a TopologyGraph which allows access to the Edges and Nodes required.
But you don't need to use C#/VB.NET/VBA to pull this off. It would be possible with the API ESRI provides with its Python scripting object (IDispatch), as that contains start and end points in its Geometry object, or by creating your own node/tree structure.
I understand this is a fairly elementary use of recursion, but as a novice programmer its a lot of fun putting it into action for a real project.
Labels:
GIS,
Nerd Stuff,
Programming,
Science,
Software
Subscribe to:
Post Comments (Atom)
2 comments:
Nice insight... I think it just goes to show that the power of a program isn't in it's complexity, but in the solution is creates...
P.S. Now that I am both a certified sailboat person & SCUBA dude, any thoughts on good ocean map software?
I imagine this is kids stuff compared to some of the networks you are involved with.
I don't know of any software specific to ocean mapping unfortunately. The primary thing I use as mapping software is ArcGIS which is generally cost-prohibitive for individuals. There are open source things that mimic it (QGIS, uDig) and publicly available bathymetry data. The scale might be fairly unhelpful for diving though.
Another option is just using Google Earth with a KML from here for trip planning.
Haha, once again I probably don't have any more insight on this particular topic than the first Google search results could yield.
Post a Comment