In this tutorial, we build an end-to-end spatial graph learning pipeline using city2graph (https://github.com/c2g-dev/city2graph). We begin by collecting real urban Points of Interest (POI) data and street network information from OpenStreetMap via OSMnx, with a synthetic fallback to ensure workflow reliability even when live data is unavailable. We then engineer spatial features, construct multiple families of proximity graphs, and compare how different graph-building strategies represent the same urban environment. Next, we create both heterogeneous and homogeneous graph structures, convert them into PyTorch Geometric (PyG) format, and train a GraphSAGE model to predict POI categories from spatial structure alone. By integrating geospatial data with modern graph neural network architectures, this implementation provides a practical foundation for intelligent urban function inference—such as identifying commercial, residential, or recreational zones—relevant to smart city initiatives in 2026 and beyond.
via MarkTechPost
