Geo-NX : Geospatial Network Analysis
Project description
Geo-NX : Geospatial Network Analysis 
Geo-NX is a Python package for the creation, manipulation, and study of geospatial networks.
Geo-NX extends NetworkX operations to allow operations on geometric types.
The Geo-NX package was created as part of the Qualicharge project
Description
Geo-NX combines the capabilities of NetworkX, GeoPandas and shapely :
- NetworkX is the core of Geo-NX,
- GeoPandas is the support for vectorized processing,
- Geo-NX uses shapely for geometry analysis and manipulation
Documentation is available at https://loco-labs.github.io/geo_nx/
Data structures
geo_nx.GeoGraph is a subclass of networkx.Graph with additional data:
- 'crs': coordinate reference system,
- 'geometry': geospatial representation of nodes and edges.
A geo_nx.GeoGraph has two representations:
- a
networkx.Graphrepresentation where 'crs' is a graph attribute and 'geometry' is a node and edge attribute (shapely object), - a
geopandas.GeoDataFramerepresentation for the nodes and for the edges where columns are id (node or edge) and attributes.
Example
Simple distance from Paris to Marseille
In [1]: import geo_nx as gnx
paris = Point(2.3514, 48.8575)
lyon = Point(4.8357, 45.7640)
marseille = Point(5.3691, 43.3026)
bordeaux = Point(-0.56667, 44.833328)
In [2]: simplemap = gpd.GeoDataFrame({
'geometry': [
LineString([paris, lyon]),
LineString([lyon, marseille]),
LineString([paris, bordeaux]),
LineString([bordeaux, marseille])
]}, crs=4326).to_crs(2154)
In [3]: gr_simplemap = gnx.from_geopandas_edgelist(simplemap)
In [4]: gr_simplemap.to_geopandas_nodelist()
Out[4]:
geometry node_id
0 POINT (652411.148 6862135.813) 0
1 POINT (842666.659 6519924.367) 1
2 POINT (892313.068 6247711.351) 3
3 POINT (418208.312 6421272.355) 2
In [5]: # 0: paris, 1: lyon, 2: bordeaux, 3: marseille
# weight is a calculated attribute (length of a geometry)
nx.shortest_path(gr_simplemap, source=0, target=3, weight='weight')
Out[5]: [0, 1, 3]
In [6]: nx.shortest_path_length(gr_simplemap, source=0, target=3, weight='weight')
Out[6]: 668246.1446978811
Install
Install the latest released version of Geo-NX:
pip install geo_nx
Bugs
Please report any bugs that you find here. Or, even better, fork the repository on GitHub and create a pull request (PR).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geo_nx-0.2.0.tar.gz.
File metadata
- Download URL: geo_nx-0.2.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c408a0ffa33055997331c418a96def5dd75463b0993d82e408aa93cb9c1e93fc
|
|
| MD5 |
5fb80d33b02f5499ebaebd24e707eaf8
|
|
| BLAKE2b-256 |
a5dd25f692acebf99d95b7c09eba293cafcd9fff53fa4e83e36260605f386d60
|
File details
Details for the file geo_nx-0.2.0-py3-none-any.whl.
File metadata
- Download URL: geo_nx-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64be18684f12d5c7ed85d6e3f5b6d2cda0442e7fb353cd8700168abc1304ab61
|
|
| MD5 |
db90fe0aeab452bedd96fa8a8c0579f6
|
|
| BLAKE2b-256 |
2d0cc85fb98e7410af89df5b0ffb980ea86bf0f22c5642236e8e353c618bc6e7
|