net2
Overview
net2 is a Python package for working with spatial networks.
Data structures
net2 is intended to work with spatial network data represented using
networkx.DiGraph objects, following several conventions:
- An object of type
nx.Graphornx.DiGraph - The network is associated with:
'crs'(Noneorint)
- Node IDs are
int - Nodes are associated with:
'geometry'(shapely)
- Edges are associated with:
'geometry'(shapely)'length'(float, in $m$)'time'(float, in $sec$)
Installation
The package can be installed with:
pip install net2
Use
Once installed, the package can be loaded with:
import net2
Sample data
The package comes with a small spatial network for demonstration, accessible as follows:
G = net2.data['roads']
G
<networkx.classes.digraph.DiGraph at 0x7f2bfcedffe0>
Here is a plot of the network:
import matplotlib.pyplot as plt
import networkx as nx
fig, ax = plt.subplots()
nx.draw(G, with_labels=True, pos=net2.pos(G))
ax.set_aspect('equal')
Example
Calculating the shortest route between two custom points, using
net2.route2:
import shapely
pnt1 = shapely.Point(4100, 3100)
pnt2 = shapely.Point(1100, 3700)
x = net2.route2(G, pnt1, pnt2, 'length')
x
Plot of the resulting route and modified network:
fig, ax = plt.subplots()
nx.draw(x['network'], with_labels=True, pos=net2.pos(x['network']), edge_color='grey', width=0.1, ax=ax)
nx.draw_networkx_edges(G, pos=net2.pos(x['network']), edgelist=list(zip(x['route'], x['route'][1:])), edge_color='r', width=3)
plt.plot(pnt1.x, pnt1.y, 'ro')
plt.plot(pnt2.x, pnt2.y, 'ro')
ax.annotate('pnt1', [pnt1.x, pnt1.y], ha='left')
ax.annotate('pnt2', [pnt2.x, pnt2.y], ha='left')
plt.axis('on')
ax.set_aspect('equal')
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True);
Metadata
Release files for net2 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| net2-0.1.1.tar.gz | 3.8 MB | Without provenance | Details for net2-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| net2-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for net2-0.1.1-py3-none-any.whl |
Total release size: 3.8 MB
Release files / net2-0.1.1.tar.gz
| Download URL | net2-0.1.1.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
733f3bb5ebd93f19448e021cef398415cb5a13898b4bae986dbd7e93c8bcd8c7
|
|
BLAKE2b-256 checksum How to use checksums |
6cc8afb9b723ae0978f73fe10ff35ca0af88c6f3b9e47db7845488e2e1a2dda9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / net2-0.1.1-py3-none-any.whl
| Download URL | net2-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c57f2c6575f5e88103be9488ed779bd836fa4017f3dc280448d50f444fe7510
|
|
BLAKE2b-256 checksum How to use checksums |
5af7dca43d1c05656a3bac66321ff2cb2ed644cc05a28c0298e051ade4a1ac9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for net2 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.