Skip to main content

Geo-NX : Geospatial Network Analysis

Project description

Geo-NX : Geospatial Network Analysis geo_nx

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.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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geo_nx-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

geo_nx-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file geo_nx-0.1.0.tar.gz.

File metadata

  • Download URL: geo_nx-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for geo_nx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f19f8eac295f97d414f4bdc7d36f56ca17c82b364905386f242b68bd23e88dde
MD5 3ad7eb8782f1d400ddcb41694fa9a275
BLAKE2b-256 f199398b257560afdff1b017c74fd8a5a149f2636a2177d6a0e9a7804b4de2d1

See more details on using hashes here.

File details

Details for the file geo_nx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: geo_nx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for geo_nx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 829bdba0fa0d52c86461b5a05f5c54d76fd939197e770803a36be87abdba6b7a
MD5 5c990693a2b0d7930ee01afda6e16aaf
BLAKE2b-256 900610ad071d61889f7709017ef70d8554d16d200780ccf4c1a3cae6d8e9f672

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page