read_shp¶
-
read_shp
(path, simplify=True)[source]¶ Generates a networkx.DiGraph from shapefiles. Point geometries are translated into nodes, lines into edges. Coordinate tuples are used as keys. Attributes are preserved, line geometries are simplified into start and end coordinates. Accepts a single shapefile or directory of many shapefiles.
“The Esri Shapefile or simply a shapefile is a popular geospatial vector data format for geographic information systems software [1].”
Parameters: - path (file or string) – File, directory, or filename to read.
- simplify (bool) – If
True
, simplify line geometries to start and end coordinates. IfFalse
, and line feature geometry has multiple segments, the non-geometric attributes for that feature will be repeated for each edge comprising that feature.
Returns: G
Return type: NetworkX graph
Examples
>>> G=nx.read_shp('test.shp')
References
[1] http://en.wikipedia.org/wiki/Shapefile