API reference


spaghetti.Network.extract_components(self, w)

Extract connected component information from a libpysal.weights.weights.W object


Using the existing network representation, create a graph-theoretic representation by removing all vertices with a neighbor incidence of two (non-articulation points).

spaghetti.Network.contiguityweights(self[, …])

Create a contiguity-based libpysal W object.

spaghetti.Network.distancebandweights(self, …)

Create distance based weights.

spaghetti.Network.snapobservations(self, …)

Snap a point pattern shapefile to network object.


Given an observation on a network arc, return the distance to the two vertices that bound that end.

spaghetti.Network.compute_snap_dist(self, …)

Given an observation snapped to a network arc, calculate the distance from the original location to the snapped location.

spaghetti.Network.count_per_link(self, obs_on)

Compute the counts per arc or edge (link).


Generate a simulated point pattern on the network.

spaghetti.Network.enum_links_vertex(self, v0)

Returns the arcs (links) around vertices.

spaghetti.Network.full_distance_matrix(self, …)

All vertex-to-vertex distances on a network.

spaghetti.Network.allneighbordistances(self, …)

Compute either all distances between i and j in a single point pattern or all distances between each i from a source pattern and all j from a destination pattern.


Compute the interpattern nearest neighbor distances or the intrapattern nearest neighbor distances between a source pattern and a destination pattern.

spaghetti.Network.split_arcs(self, distance)

Split all of the arcs in the network at a fixed distance.

spaghetti.Network.savenetwork(self, filename)

Save a network to disk as a binary file.


Load a network from a binary file saved on disk.

spaghetti.Network.NetworkF(self, pointpattern)

Computes a network constrained F-Function

spaghetti.Network.NetworkG(self, pointpattern)

Computes a network constrained G-Function

spaghetti.Network.NetworkK(self, pointpattern)

Computes a network constrained K-Function

spaghetti.Network._evaluate_napts(self, …)

Evaluate one connected component in a network for non-articulation points (napts) and return an updated set of napts and unvisted vertices.


Used internally to extract a network from a polyline shapefile of a geopandas.GeoDataFrame.

spaghetti.Network._newpoint_coords(self, …)

Used internally to compute new point coordinates during snapping.

spaghetti.Network._round_sig(self, v)

Used internally to round the vertex to a set number of significant digits.

spaghetti.Network._snap_to_link(self, …)

Used internally to snap point observations to network arcs.


Find all nodes with degree 2 that are not in an isolated island ring (loop) component.

spaghetti.Network._yieldneighbor(self, vtx, …)

Used internally, this method traverses a bridge arc to find the source and destination nodes.


spaghetti.PointPattern([in_data, …])

A stub point pattern class used to store a point pattern.



Struct style class to mirror the PointPattern class.


spaghetti.element_as_gdf(net[, vertices, …])

Return a geopandas.GeoDataFrame of network elements.This can be (a) the vertices of a network; (b) the arcs of a network; (c) both the vertices and arcs of the network; (d) raw point pattern associated with the network; or (e) snapped point pattern of (d)..