spacenet.utils.spatial_network_from_edgelist#
- spacenet.utils.spatial_network_from_edgelist(points, edgelist, inverse_distance_function=None)#
Generates a spatial network from a given edgelist and node coordinates. The function creates a NetworkX graph object, adds nodes and edges, and computes inverse distances for the edges based on the provided or default inverse distance function. Edge weights for ‘Distance’ and ‘Inverse Distance’ will be added to the network. Node indices correspond to the indices of the input points array. Nodes will have a ‘position’ attribute corresponding to their spatial coordinates from the input points array.
- Parameters:
- pointsnumpy.ndarray
An array of shape (n, 2) representing the coordinates of the nodes in the network. Points should be ordered in ascending order of node ids in the edgelist.
- edgelistlist of tuples
A list of tuples (node1, node2, weight) representing the edges of the network.
- inverse_distance_functioncallable, optional
A function that takes a distance as an argument and returns an inverse distance value.
- Returns:
- Gnetworkx.Graph
A NetworkX graph object representing the spatial network, with nodes and edges added.