Retour au classement

c2g-dev/city2graph

Pythoncity2graph.net

Transform geospatial relations into graphs for Graph Neural Networks and spatial network analysis

network-analysisspatial-analysisgeographical-information-systemgraph-neural-networkspytorchpytorch-geometricgeographic-data-sciencegraph-representation-learningmobilitytransportationgisurban-morphometrics
Croissance des étoiles
Étoiles
1.3k
Forks
139
Croissance hebdomadaire
Issues
2
5001k
avr. 2025sept. 2025févr. 2026juil. 2026
ArtefactsPyPIpip install city2graph
README

City2Graph: Geospatial Graphs for Network Analysis and GNNs

City2Graph

City2Graph is a Python library that turns buildings, streets, public transport feeds, origin–destination matrices, zones, and points of interest into spatial and heterogeneous graphs. It bridges GeoPandas, NetworkX, and PyTorch Geometric so the same geospatial data can support network analysis, urban research, and Graph Neural Networks (GNNs). See the documentation for installation, tutorials, and the Python API reference.

PyPI version conda-forge Version PyPI Downloads DOI License Platform codecov Ruff

Features

City2Graph workflow from geospatial data to graph analysis

  • Morphology: Graphs of buildings, streets, and tessellated urban fabric from OpenStreetMap and Overture Maps.
  • Transportation: GTFS public transport and GBFS shared-mobility feeds loaded into DuckDB, with GTFS aggregated into stop-to-stop transit graphs.
  • Mobility: Origin–destination matrices and flow data — migration, bike-sharing, pedestrian counts — as weighted spatial graphs.
  • Proximity and Contiguity: KNN, Delaunay, Gilbert, and Waxman graphs plus queen/rook contiguity, under Euclidean, Manhattan, or network distances.
  • Heterogeneous Graphs and Metapaths: Multiple node and edge types in one graph, with metapath-derived edges composing relations across them.
  • GNN-ready Tensors: Round-trip conversion between GeoDataFrames, NetworkX, and PyTorch Geometric Data/HeteroData.

Installation

Using pip

Basic Installation

The simplest way to install City2Graph is via pip:

pip install city2graph

This installs the core functionality without PyTorch and PyTorch Geometric.

With PyTorch (CPU)

If you need the Graph Neural Networks functionality, install with the cpu option:

pip install "city2graph[cpu]"

This will install PyTorch and PyTorch Geometric with CPU support, suitable for development and small-scale processing.

With PyTorch + CUDA (GPU)

For GPU acceleration, you can install City2Graph with a specific CUDA version extra. For example, for CUDA 13.0:

pip install "city2graph[cu130]"

Supported CUDA versions are cu126, cu128, and cu130. The cpu, cu126, and cu130 extras use PyTorch 2.12 or newer. Because PyTorch 2.12 no longer publishes CUDA 12.8 wheels, cu128 uses PyTorch 2.11.

Using conda

Basic Installation

You can also install City2Graph using conda from conda-forge:

conda install -c conda-forge city2graph

This installs the core functionality without PyTorch and PyTorch Geometric.

With PyTorch (CPU)

To use PyTorch and PyTorch Geometric with City2Graph installed from conda-forge, you need to manually add these libraries to your environment:

# Install city2graph
conda install -c conda-forge city2graph

# Then install PyTorch and PyTorch Geometric
conda install -c conda-forge pytorch pytorch_geometric

With PyTorch + CUDA (GPU)

For GPU support, you should select the appropriate PyTorch variant by specifying the version and CUDA build string. For example, to install PyTorch 2.12.0 with CUDA 13.0 support:

# Install city2graph
conda install -c conda-forge city2graph

# Then install PyTorch with CUDA support
conda install -c conda-forge pytorch=2.12.0=*cuda130*
conda install -c conda-forge pytorch_geometric

You can browse available CUDA-enabled builds on the conda-forge PyTorch files page and substitute the desired version and CUDA variant in your install command. Make sure that the versions of PyTorch and PyTorch Geometric you install are compatible with each other and with your system.

⚠️ Important: conda is not officially supported by PyTorch and PyTorch Geometric anymore, and only conda-forge distributions are available for them. We recommend using pip or uv for the most streamlined installation experience if you need PyTorch functionality.

For Development

See the Contributing Guide for the canonical development setup, testing, code quality, documentation, and pull request instructions.

Citation

If you use City2Graph in your research, please cite it as follows:

@software{sato2025city2graph,
  title = {City2Graph: Transform geospatial relations into graphs for spatial network analysis and Graph Neural Networks},
  author = {Sato, Yuta},
  year = {2025},
  url = {https://github.com/c2g-dev/city2graph},
  doi = {10.5281/zenodo.15858845},
}

You can also use the DOI to cite a specific version: DOI

Alternatively, you can find the citation information in the CITATION.cff file in this repository, which follows the Citation File Format standard.

Contributing

Contributions are welcome. The Contributing Guide contains the complete development and quality requirements.

Documentation

City2Graph uses MkDocs for current documentation (v0.2.0+) and keeps Sphinx for legacy releases (v0.1.0–v0.1.7).

  • Legacy tags (v0.1.*): Read the Docs builds docs/source via Sphinx.
  • Everything else (branches / newer tags): Read the Docs builds via MkDocs (mkdocs.yml).

This is controlled in .readthedocs.yaml using READTHEDOCS_VERSION_TYPE and READTHEDOCS_VERSION_NAME.

GeoGraphic Data Science Lab

Dépôts similaires
GyulyVGC/sniffnet

Comfortably monitor your Internet traffic 🕵️‍♂️

Rustcrates.ioApache License 2.0network-analysisnetworking
sniffnet.app
40.1k1.8k
txthinking/brook

A cross-platform programmable network tool

GoGo ModulesGNU General Public License v3.0proxyvpn
txthinking.com/brook.html
15.1k2.4k
OWASP/mastg

The OWASP Mobile Application Security Testing Guide (MASTG) is a comprehensive manual for mobile app security testing and reverse engineering. It describes technical processes for verifying the OWASP Mobile Security Weakness Enumeration (MASWE) weaknesses, which are in alignment with the OWASP MASVS.

PythonPyPICreative Commons Attribution Share Alike 4.0 Internationalmobile-apppentesting
mas.owasp.org
13.1k2.8k
secdev/scapy

Scapy: the Python-based interactive packet manipulation program & library.

PythonPyPIGNU General Public License v2.0scapypython
scapy.net
12.4k2.2k
OWASP/owasp-mastg

The Mobile Application Security Testing Guide (MASTG) is a comprehensive manual for mobile app security testing and reverse engineering. It describes the technical processes for verifying the controls listed in the OWASP Mobile Application Security Verification Standard (MASVS).

PythonPyPICreative Commons Attribution Share Alike 4.0 Internationalmobile-apppentesting
mas.owasp.org
12k2.4k
kubeshark/kubeshark

eBPF-powered network observability for Kubernetes. Indexes L4/L7 traffic with full K8s context, decrypts TLS without keys. Queryable by AI agents via MCP and humans via dashboard.

GoGo ModulesApache License 2.0kubernetesgolang
kubeshark.com
12k542
clips/pattern

Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.

PythonPyPIBSD 3-Clause "New" or "Revised" Licensepythonmachine-learning
github.com/clips/pattern/wiki
8.9k1.6k
nxtrace/NTrace-core

NextTrace, an open source visual route tracking CLI tool

GoGo ModulesGNU General Public License v3.0tracerouteapi
nxtrace.org
8k480
netalertx/NetAlertX

Centralized network visibility and continuous asset discovery. Monitor devices, detect change, and stay aware across distributed networks.

PythonPyPIGNU General Public License v3.0network-securityselfhosted
netalertx.com
6.8k426
tanprathan/MobileApp-Pentest-Cheatsheet

The Mobile App Pentest cheat sheet was created to provide concise collection of high value information on specific mobile application penetration testing topics.

mobile-apppentesting
5.2k1.3k
scanopy/scanopy

Network diagrams that update themselves

Rustcrates.ioGNU Affero General Public License v3.0homelabnetwork-analysis
scanopy.net
5.2k255
ChuckerTeam/chucker

🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device)

KotlinApache License 2.0okhttpinterceptor
4.5k459