City2Graph
v1.0.0 open-sourceTransform geospatial relations into graphs for Graph Neural Networks and spatial network analysis
import city2graph graphs = city2graph.morphological_graphs(buildings_gdf, tessellation_gdf)
Summary
City2Graph is an open-source Python library that transforms buildings, streets, transport feeds, and point-of-interest data into spatial and heterogeneous graphs. It is licensed under the BSD 3-Clause license and functions as a library imported into other code. It is intended for researchers and data scientists working with geospatial data, sitting in the graph-analysis space adjacent to tools like NetworkX. The project shows signs of ongoing development, with 17 releases tracked in our records.
Transform geospatial relations into graphs for Graph Neural Networks and spatial network analysis
What City2Graph answers
What kinds of real-world data elements does it model into a graph?
buildings, streets, public transport feeds, origin–destination matrices, zones, and points of interest
Which existing Python data science libraries does it accommodate for graph creation?
GeoPandas, NetworkX, and PyTorch Geometric
What methods of mobility data can it incorporate?
origin–destination matrices and flow data such as migration, bike-sharing, and pedestrian counts
What external data feeds can it process for transportation information?
GTFS public transport and GBFS shared-mobility feeds
Does it handle different types of physical structures in the urban environment?
Yes, it handles buildings, streets, and tessellated urban fabric
Examples
Command line
No option matches that search.
| option | found in | since | description |
|---|
No option matches that search.
Values are placeholders taken from each option’s declared default. Nothing is executed here — the output shown is a recording of a run that already happened.
Release history
- v1.0.0
City2Graph v1.0.0 adds morphological_graphs(), GBFS shared-mobility loading, and deprecates the
as_nxparameter.└──▷ GET THIS VERSION$ git clone --branch v1.0.0 https://github.com/c2g-dev/city2graph.git # already have the repo? check out this version: $ git checkout v1.0.0
└──▷ USE ITBuild morphological graphs for multiple urban areas in one call using the new batch function.import city2graph graphs = city2graph.morphological_graphs(buildings_gdf, tessellation_gdf)
- ›Adds morphological_graphs() function (plural) for batch morphological graph construction, with improved error handling for
GeometryCollectioninputs. - ›Expands options on morphological_graph() (singular) for finer control over morphological graph generation.
- ›Adds GBFS shared-mobility feed loading support, joining the existing GTFS pipeline for transit data ingestion into DuckDB.
- ›Adds
DeprecationWarningon theas_nxparameter to signal its forthcoming removal. - ›Replaces dense proximity distance matrices with sparse neighbor queries, reducing memory pressure for large spatial graphs.
- ›Adds morphological_graphs() function (plural) for batch morphological graph construction, with improved error handling for