Created
February 7, 2012 23:52
-
-
Save bwreilly/1763097 to your computer and use it in GitHub Desktop.
nx_spatial, networkx for trivial spatial graph processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgisscripting as arc | |
import nx_spatial as ns | |
# add the fcs to networkx network | |
G = ns.read_fc(workingdir, gp) | |
tx = ns.attr_find(G, FcName="Transformer") | |
#break up net into connected components | |
components = nx.connected_components(G.to_undirected()) | |
for c in components: | |
tl = filter(lambda n: n in tx, c) | |
if tl: | |
t = tl[0] # the transformer | |
services = filter(lambda n: n in servicepoints, c) | |
for sp in services: | |
tx_id = G.node[t].get('TxKey') | |
sp_acc = G.node[sp].get('ServiceKey') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
import nx_spatial as ns | |
# add the shapes to networkx network | |
G = ns.read_shp(workingdir) | |
tx = ns.attr_find(G, Name="Transformer") | |
# then the same as above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment