Skip to content

New to python, do we have to save the graph and if so how? #11

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions