Your city, but as a graph your GNN can actually read
A Python bridge that turns messy geospatial data—streets, transit feeds, building footprints—into PyTorch Geometric tensors without the usual hand-rolled pain.

What it does City2Graph converts urban geospatial datasets into graph representations for network analysis and Graph Neural Networks. It wraps GeoPandas, NetworkX, and PyTorch Geometric into a single interface, handling streets, transit networks, POI proximities, mobility flows, and land-use adjacency.
The interesting bit The GTFS integration is the quiet standout: it queries transit feeds through DuckDB and builds detailed accessibility graphs, which is the kind of plumbing most people rebuild badly. The library also handles multi-center distance filtering and layered isochrones—spatial operations that sound routine until you try to implement them yourself.
Key highlights
- Builds graphs from buildings, streets, land use, and OD matrices
- Queries GTFS feeds via DuckDB for transit network modeling
- Supports proximity, contiguity, and mobility flow analysis (bike-sharing, migration, pedestrian)
- Converts geospatial data directly to PyTorch Geometric tensors
- Available on PyPI and conda-forge with optional CPU/GPU PyTorch extras
- BSD-3-Clause license with a Zenodo DOI for citation
Caveats
- The README warns that conda is “not officially supported by PyTorch and PyTorch Geometric anymore” and recommends pip or uv instead
- Documentation is split across two systems: MkDocs for v0.2.0+, Sphinx for legacy v0.1.x releases
- One Docker Compose example still points to
yu-ta-sato/city2graphrather than thec2g-devorg, suggesting a minor migration cleanup gap
Verdict Worth a look if you’re doing urban GNN research or spatial network analysis and tired of writing conversion glue. Skip it if your graphs don’t have a geographic component—this is purpose-built for cities, not general graph construction.
Frequently asked
- What is c2g-dev/city2graph?
- A Python bridge that turns messy geospatial data—streets, transit feeds, building footprints—into PyTorch Geometric tensors without the usual hand-rolled pain.
- Is city2graph open source?
- Yes — c2g-dev/city2graph is open source, released under the BSD-3-Clause license.
- What language is city2graph written in?
- c2g-dev/city2graph is primarily written in Python.
- How popular is city2graph?
- c2g-dev/city2graph has 1.3k stars on GitHub.
- Where can I find city2graph?
- c2g-dev/city2graph is on GitHub at https://github.com/c2g-dev/city2graph.