A Coding Implementation on Spatial Graph Neural Networks for Urban Function Inference Using city2graph, OSMnx, and PyTorch Geometric

This tutorial demonstrates building a spatial graph learning pipeline for urban function inference. It uses city2graph, OSMnx, and PyTorch Geometric to collect urban data, construct various proximity graphs, and train a GraphSAGE model to predict points of interest categories from spatial structures. The process integrates geospatial data processing, graph construction, and GNN-based urban function inference into a single workflow.
This tutorial outlines an end-to-end spatial graph learning pipeline using city2graph for urban function inference. The process begins with collecting real urban Point of Interest (POI) data and street network information from OpenStreetMap, with a synthetic data fallback for workflow reliability. This initial step ensures a robust dataset for analysis, regardless of online data availability.
Following data acquisition, the tutorial focuses on engineering spatial features and constructing multiple proximity graph families. It compares different graph-building strategies to represent the same urban environment effectively. This stage is crucial for understanding how spatial relationships influence urban patterns.
The pipeline then progresses to creating both heterogeneous and homogeneous graph structures, converting them into PyTorch Geometric format. A GraphSAGE model is subsequently trained to predict POI categories based on spatial structure. This demonstrates the application of graph neural networks (GNNs) in interpreting complex urban data.
The overall workflow integrates geospatial data processing, graph construction, and GNN-based urban function inference. This comprehensive approach provides a practical method for analyzing and understanding urban environments through their spatial and functional characteristics.
Related articles
The AI world is getting ‘loopy’
AI models are taking a significant leap forward with the adoption of "agentic loops," where AI agents continuously prompt each other to improve code and solve complex problems. This approach, though potentially resource-intensive, promises to unlock new levels of autonomous problem-solving and efficiency in AI applications.
Codex-maxxing for long-running work
Codex is increasingly being used by organizations to support long-running projects that go beyond a single prompt. This whitepaper by Jason Liu offers practical strategies for leveraging Codex as a persistent workspace, managing complex workflows and sustaining progress.
Nobel laureate John Jumper is leaving DeepMind for rival Anthropic
Nobel laureate John Jumper is departing Google DeepMind to join its competitor, Anthropic, after dedicating nearly nine years to DeepMind, where he led the AlphaFold team. Jumper, who shared a Nobel Prize for his work on AlphaFold, expressed gratitude for his time at DeepMind while looking forward to new endeavors.
