# Geo-NX : Geospatial Network Analysis <img src="https://github.com/loco-labs/geo_nx/blob/main/docs/geo_nx.png" alt="geo_nx" style="float:right;width:100px;height:90px;">
Geo-NX is a [Python package](https://github.com/loco-labs/geo_nx) 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](https://github.com/MTES-MCT/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.Graph` representation where 'crs' is a graph attribute and 'geometry'
is a node and edge attribute (shapely object),
- a `geopandas.GeoDataFrame` representation for the nodes and for the edges where columns are id (node or edge) and attributes.
## Example
Simple distance from Paris to Marseille
```python
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:
```shell
pip install geo_nx
```
## Bugs
Please report any bugs that you find [here](https://github.com/loco-labs/geo_nx/issues).
Or, even better, fork the repository on GitHub and create a pull request (PR).
Raw data
{
"_id": null,
"home_page": "https://github.com/loco-labs/geo_nx/blob/main/README.md",
"name": "geo-nx",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.11",
"maintainer_email": null,
"keywords": "network, geographic, geospatial, open data",
"author": "Philippe Thomy",
"author_email": "philippe@loco-labs.io",
"download_url": "https://files.pythonhosted.org/packages/a5/dd/25f692acebf99d95b7c09eba293cafcd9fff53fa4e83e36260605f386d60/geo_nx-0.2.0.tar.gz",
"platform": null,
"description": "# Geo-NX : Geospatial Network Analysis <img src=\"https://github.com/loco-labs/geo_nx/blob/main/docs/geo_nx.png\" alt=\"geo_nx\" style=\"float:right;width:100px;height:90px;\">\r\n\r\nGeo-NX is a [Python package](https://github.com/loco-labs/geo_nx) for the creation, manipulation, and study of geospatial networks.\r\n\r\nGeo-NX extends NetworkX operations to allow operations on geometric types.\r\n\r\n*The Geo-NX package was created as part of the [Qualicharge](https://github.com/MTES-MCT/qualicharge) project*\r\n\r\n## Description\r\n\r\nGeo-NX combines the capabilities of NetworkX, GeoPandas and shapely :\r\n\r\n- NetworkX is the core of Geo-NX,\r\n- GeoPandas is the support for vectorized processing,\r\n- Geo-NX uses shapely for geometry analysis and manipulation \r\n\r\nDocumentation is available at https://loco-labs.github.io/geo_nx/\r\n\r\n## Data structures\r\n\r\n`geo_nx.GeoGraph` is a subclass of `networkx.Graph` with additional data:\r\n\r\n- 'crs': coordinate reference system,\r\n- 'geometry': geospatial representation of nodes and edges.\r\n\r\nA `geo_nx.GeoGraph` has two representations:\r\n\r\n- a `networkx.Graph` representation where 'crs' is a graph attribute and 'geometry' \r\nis a node and edge attribute (shapely object),\r\n- a `geopandas.GeoDataFrame` representation for the nodes and for the edges where columns are id (node or edge) and attributes.\r\n\r\n## Example\r\n\r\nSimple distance from Paris to Marseille\r\n\r\n```python\r\nIn [1]: import geo_nx as gnx\r\n \r\n paris = Point(2.3514, 48.8575)\r\n lyon = Point(4.8357, 45.7640)\r\n marseille = Point(5.3691, 43.3026)\r\n bordeaux = Point(-0.56667, 44.833328)\r\n\r\nIn [2]: simplemap = gpd.GeoDataFrame({\r\n 'geometry': [\r\n LineString([paris, lyon]), \r\n LineString([lyon, marseille]), \r\n LineString([paris, bordeaux]), \r\n LineString([bordeaux, marseille])\r\n ]}, crs=4326).to_crs(2154)\r\n\r\nIn [3]: gr_simplemap = gnx.from_geopandas_edgelist(simplemap)\r\n\r\nIn [4]: gr_simplemap.to_geopandas_nodelist()\r\nOut[4]:\r\n geometry node_id\r\n 0 POINT (652411.148 6862135.813) 0\r\n 1 POINT (842666.659 6519924.367) 1\r\n 2 POINT (892313.068 6247711.351) 3\r\n 3 POINT (418208.312 6421272.355) 2\r\n\r\nIn [5]: # 0: paris, 1: lyon, 2: bordeaux, 3: marseille\r\n # weight is a calculated attribute (length of a geometry)\r\n nx.shortest_path(gr_simplemap, source=0, target=3, weight='weight')\r\nOut[5]: [0, 1, 3]\r\n\r\nIn [6]: nx.shortest_path_length(gr_simplemap, source=0, target=3, weight='weight')\r\nOut[6]: 668246.1446978811\r\n```\r\n\r\n## Install\r\n\r\nInstall the latest released version of Geo-NX:\r\n\r\n```shell\r\npip install geo_nx\r\n```\r\n\r\n## Bugs\r\n\r\nPlease report any bugs that you find [here](https://github.com/loco-labs/geo_nx/issues). \r\nOr, even better, fork the repository on GitHub and create a pull request (PR).\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Geo-NX : Geospatial Network Analysis",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/loco-labs/geo_nx/blob/main/README.md"
},
"split_keywords": [
"network",
" geographic",
" geospatial",
" open data"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2d0cc85fb98e7410af89df5b0ffb980ea86bf0f22c5642236e8e353c618bc6e7",
"md5": "db90fe0aeab452bedd96fa8a8c0579f6",
"sha256": "64be18684f12d5c7ed85d6e3f5b6d2cda0442e7fb353cd8700168abc1304ab61"
},
"downloads": -1,
"filename": "geo_nx-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "db90fe0aeab452bedd96fa8a8c0579f6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.11",
"size": 12896,
"upload_time": "2024-10-06T20:54:12",
"upload_time_iso_8601": "2024-10-06T20:54:12.978125Z",
"url": "https://files.pythonhosted.org/packages/2d/0c/c85fb98e7410af89df5b0ffb980ea86bf0f22c5642236e8e353c618bc6e7/geo_nx-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a5dd25f692acebf99d95b7c09eba293cafcd9fff53fa4e83e36260605f386d60",
"md5": "5fb80d33b02f5499ebaebd24e707eaf8",
"sha256": "c408a0ffa33055997331c418a96def5dd75463b0993d82e408aa93cb9c1e93fc"
},
"downloads": -1,
"filename": "geo_nx-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "5fb80d33b02f5499ebaebd24e707eaf8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.11",
"size": 13658,
"upload_time": "2024-10-06T20:54:14",
"upload_time_iso_8601": "2024-10-06T20:54:14.563115Z",
"url": "https://files.pythonhosted.org/packages/a5/dd/25f692acebf99d95b7c09eba293cafcd9fff53fa4e83e36260605f386d60/geo_nx-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-06 20:54:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "loco-labs",
"github_project": "geo_nx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "geo-nx"
}