Mapping cities with AI: A new way to infer urban functions

A fresh Python tutorial shows how spatial graph neural networks can turn raw city data into insights about urban functions. The open-source workflow, built around libraries like city2graph, OSMnx, and PyTorch Geometric, walks through collecting points of interest from OpenStreetMap, engineering spatial features, and training a GraphSAGE model to predict categories such as food, retail, education, and health.
From streets to graphs
The process begins by fetching real POI data and street networks from OpenStreetMap, with a synthetic fallback that keeps the pipeline running even when live data is unavailable. After cleaning the data, the tutorial engineers multiple proximity graphs—each capturing a different way of linking points of interest and street segments—so users can compare how graph design affects the final model. Homogeneous and heterogeneous graph structures are then built and converted into PyTorch Geometric format for training.
Training a spatial learner
With the data prepared, the workflow trains a GraphSAGE model to infer POI categories from the spatial structure alone. A fixed random seed ensures reproducible splits and results, while standard machine-learning metrics track accuracy and F1 scores. The combination of geospatial data processing, graph construction, and graph neural networks offers a practical template for urban planners, researchers, and data scientists looking to automate urban function inference without costly manual labeling.
Source: MarkTechPost. AI-assisted editorial synthesis — TechnoExpress.

