I have two shapefiles of roads in the city of San Francisco, one obtained via the US Census and one via SFData.
I'd like to use the second one, it seems more filled out.
But when I try to find the connected subgraphs of it, I get an empty list. While for the Census version I get a healthy list of objects like <networkx.classes.graph.Graph at 0x11ef99cdb00>
.
I assumed (naively) that the SFData was a completely connected graph, but all the documentation I've read suggests in that case that I'd still return a single-element list.
What am I missing? How can I get the SF Data into a usable graph?
import networkx as nx
#sfdata
g = nx.read_shp('Road files/geo_export_93b884b0-683e-4cbe-bde2-78574254c7f2.shp')
sg = list(nx.connected_component_subgraphs(g.to_undirected()))
#census
g2 = nx.read_shp('Road files/tl_2016_06075_roads.shp')
sg2 = list(nx.connected_component_subgraphs(g2.to_undirected()))