CartoGenT: a generative multiscale Transformer framework for the amalgamation of vector-based building footprints
This repository provides the inference code, pretrained model and dataset of CartoGenT. The pretrained model and dataset are also archived on Figshare: https://doi.org/10.6084/m9.figshare.34856916.
Building amalgamation is a key operation in cartographic generalization for producing clear and coherent multiscale maps. CartoGenT is an end-to-end, vector-native generative Transformer framework for building amalgamation.
- Vector-native: operates directly on vector geometry, avoiding the precision loss of rasterization.
- Multiscale: a scale-adaptive module models cross-scale contextual dependencies.
- Generative: jointly predicts vertices and their connectivity to reconstruct topologically valid geometry.
| Path | Content |
|---|---|
cartogent_inference/, infer.py |
Inference code |
cartogent.ckpt |
Pretrained model |
dataset/ |
Dataset |
Python 3.11 or later is required.
git clone https://github.com/whtower/CartoGenT.git
cd CartoGenT
pip install -r requirements.txtpython infer.py dataset/geojson/test/data/test_1000_12_input.geojson --output prediction.jsonThe input is a GeoJSON file containing one group of building polygons without holes, with at most 64 vertices in total. Coordinates are WGS84 by default; use --crs EPSG:27700 (or another projected CRS) or --crs local for planar coordinates. Larger groups can be reduced with --simplify <tolerance>. The output file contains the amalgamated polygons in the input coordinate system.
The dataset is constructed from Ordnance Survey and OpenStreetMap vector building data of Great Britain. It contains 8,295 building groups (train 5,561; valid 775; test 1,959) in British National Grid coordinates (EPSG:27700).
dataset/
├── metadata/ sample lists of each split
├── {train,valid,test}/data/
│ ├── <id>_train.pkl source building group
│ └── <id>_label.pkl amalgamated result
└── geojson/ the same samples in WGS84 GeoJSON
Each .pkl file is a networkx.DiGraph whose edges follow the polygon rings. Nodes of source graphs store the previous, current and next vertex coordinates (feature); nodes of amalgamated graphs store the vertex coordinates (pos).
The online demo amalgamates hand-drawn buildings or buildings selected from OpenStreetMap.
The code is released under the MIT License, the pretrained model under CC BY 4.0, and the dataset under ODbL 1.0. The dataset contains data © OpenStreetMap contributors and Ordnance Survey data © Crown copyright and database right.
