I've had my computer running for seven days converting a shapefile to a graph, I used this code:
from s2g import ShapeGraph
import fiona
from shapely.geometry import shape, LineString
shp = r"C:\Users\Tom\Documents\NorthAmerica.shp"
with fiona.open(shp) as source:
geoms = []
for r in source:
s = shape(r['geometry'])
if isinstance(s, LineString):
geoms.append(s)
# create ShapeGraph object from a list of lines
sg = ShapeGraph(geoms, to_graph=False)
# detect major components
mc = sg.gen_major_components()
# major components are mc[2]
# convert the largest component to networkx Graph
graph = sg.to_networkx() # equivalently sg.graph
plt.savefig(r"C:\Users\Tom\Documents\graph.png")
was I supposed to save it to somewhere because it's finished but I don't see any kind of output in the command line.
I've had my computer running for seven days converting a shapefile to a graph, I used this code:
was I supposed to save it to somewhere because it's finished but I don't see any kind of output in the command line.