It's been more or less done a while, but here is finally a blog post about it.
nx_spatial is a collection of addon functions for the networkx python graph library. What can you do with it?
- Load GIS formats into networkx graphs (where you can do all sorts of crazy analytics on them)
- Perform upstream and downstream traces with stopping points.
- Set sources and find/repair edges that don't have the correct to/from nodes.
Example from the wiki:
>>> import nx_spatial as ns >>> net = ns.read_shp('/shapes/lines.shp') >>> net.edges() [[(1.0, 1.0), (2.0, 2.0)], [(2.0, 2.0), (3.0, 3.0)], [(0.9, 0.9), (4.0, 2.0)]] >>> net.nodes() [(1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (0.9, 0.9), (4.0, 2.0)] >>> source = (2.0, 2.0) >>> ns.setdirection(net, source) >>> net.edges() [[(2.0, 2.0), (1.0, 1.0)], [(2.0, 2.0), (3.0, 3.0)], [(0.9, 0.9), (4.0, 2.0)]]
Available on pypi or bitbucket. Eventually I want to integrate it with networkx trunk (loading shapefiles is already in 1.4).
7 comments:
I'm sure that is all very helpful and cool and interesting but seriously could you get just a little bit more nerdy? :)
Yeah. I am a damn bright woman, and I have NO clue what that is. Maybe I can just scold you for taking so long to post it?
Your mother would be so proud.. :-)
I'm not a bright woman like Unmitigated so I have no idea what you're talking about either, but your mom said to come check out your blog and you should always listen to your mother.
Gah, it helps the code came over all wonky. It is autoposted from here. Anyway, it is really just adding some stuff to a library build by people way, way smarter than I.
Funny enough, I'm actually working on cooler stuff at work at the moment (real time power outage viewer for the public). And also my more next post all about conservation.
Thanks for visiting all!
I though I was a nerd with my Jedi knowledge. Well done.
Well put. Nx_spatial is one of my favorite subjects, and of all the blogs I've read which discuss it, yours is by far the most engrossing. Okay, I'm lying, I don't have a clue. I'm just here because your mother told me to come here. She's very persuasive. You're very smart.
Post a Comment