Let’s be honest: traditional GIS software is fantastic at making beautiful maps. But the moment you try to feed that complex spatial data into a deep learning model to predict urban traffic flows or optimize transit networks? You hit a wall.
In 2026, the bottleneck for smart city initiatives isn’t collecting data—it’s translating complex urban geometries into tensors that AI can actually process.
Enter city2graph: an open-source library that builds a direct bridge between geospatial data and GeoAI. It takes the messy, interconnected reality of cities and converts it into relational graphs ready for Graph Neural Networks (GNNs). No more forcing square spatial data into round deep learning holes. Let’s break down how it works and why it matters for your spatial data stack.
How city2graph Transforms Urban Data for AI
Traditional GIS treats cities as isolated shapes and coordinates. city2graph treats them as what they actually are: living, breathing networks of complex interconnections.
Here is how the architecture handles the heavy lifting:
🏙️ Morphological Modeling
It takes urban variables—buildings, streets, land-use zones—and converts them into graph nodes. These aren’t just empty dots; they are rich with proximity, adjacency, and spatial context properties.
🔗 The Unified Ecosystem
This is where the magic happens. city2graph acts as a native, frictionless bridge between three major Python ecosystems:
- GeoPandas for spatial analysis and geometry handling
- NetworkX for traditional graph theory and network metrics
- PyTorch Geometric for deep learning and GNN training
Instead of writing clunky custom scripts to serialize data between these libraries, city2graph handles the translation natively. Your spatial data flows directly into the tensor formats your neural networks expect.
Key Features of the city2graph Library
What makes this library stand out in the GeoAI space? Here is the verified shortlist:
✅ High-Performance Transport Processing
- Integrates DuckDB for highly optimized SQL queries on GTFS (public transit) data.
- Multi-modal network analysis and accessibility calculations happen in seconds, not hours.
✅ Dynamic Mobility Analysis
- Transforms Origin-Destination (OD) matrices—like bike-sharing trips or pedestrian flows—directly into human flow networks.
- Predictive models can instantly read and process dynamic movement patterns.
✅ Seamless PyTorch Geometric Integration
- Outputs are directly compatible with GNN architectures.
- Skips the manual tensor reshaping and graph construction headaches that usually eat up weeks of research time.
✅ Open-Source & Extensible
- Fully open-source under a permissive license.
- Built for the research and developer community to adapt to any urban dataset, from megacities to small towns.
Practical Use Cases: Who Wins with city2graph?
This isn’t just an academic exercise. Here is how different professionals extract real ROI from city2graph:
🎯 Urban Planners & Smart City Developers
- Predict traffic congestion, optimize public transit routes, and model pedestrian movement.
- Focus on urban design rather than spending months writing custom data loaders.
🎯 GeoAI Researchers & Data Scientists
- Skip the data wrangling phase. Go straight from raw GIS shapefiles to training your GNN models.
- Easily experiment with different graph architectures (GCNs, GraphSAGE) on standardized urban inputs.
🎯 Logistics & Supply Chain Operations
- Model multi-modal transport networks to find inefficiencies in last-mile delivery.
- Simulate how infrastructure changes impact overall network resilience and flow.
🎯 Real Estate & Market Analysts
- Map the relational value of neighborhoods based on transit accessibility, land use, and spatial proximity.
- Feed these graphs into predictive pricing models with high spatial fidelity.
The Verdict:
city2graph removes the friction between spatial data science and deep learning. It doesn’t just visualize the city; it translates the city’s complexity into a language AI can understand. If you are working at the intersection of GIS and machine learning, this library is your new starting line.
💡 Pro FlowTip: When processing large GTFS datasets, leverage the DuckDB integration early in your pipeline. Run your heavy SQL aggregations inside DuckDB before passing the cleaned data to city2graph. That’s how you keep your memory footprint tiny and your graph generation blazing fast.

Sources: city2graph GitHub repository , official documentation on GeoPandas, NetworkX, and PyTorch Geometric integration. Current as of June 2026.