OSMGraphCLIP-MS / README.md
d-michail's picture
Initial version
0e2b470
|
Raw
History Blame Contribute Delete
6.89 kB
---
license: odbl
pretty_name: OSMGraphCLIP-MS training dataset
tags:
- openstreetmap
- geospatial
- graph
- location-encoding
- remote-sensing
- contrastive-learning
- clip
size_categories:
- 100K<n<1M
---
# OSMGraphCLIP-MS
Training dataset for the **MS** (multiscale) variant of [OSMGraphCLIP](https://github.com/d-michail/osmgraphclip): *"OSMGraphCLIP: Learning Global Location Representations from OpenStreetMap Graphs"* ([arXiv:2606.08046](https://arxiv.org/abs/2606.08046)).
It contains ~200k globally-diverse `(lat, lon)` locations, and for each location:
- a **heterogeneous OSM graph** (points, lines, polygons — roads, buildings, land use, POIs — with SBERT node features), and
- **multiscale concentric-ring "band" features** summarizing OSM content in rings around the location at multiple radii.
These pairs (graph + coordinate, with the band features as auxiliary multiscale signal) are what the graph encoder (`OSMHeteroGAT`) and location encoder (`LocationEncoder`) are contrastively aligned on. This dataset was used to train:
| Model | HuggingFace |
|---|---|
| OSMGraphCLIP-MS-L40 | [d-michail/OSMGraphCLIP-MS-L40](https://huggingface.co/d-michail/OSMGraphCLIP-MS-L40) |
| OSMGraphCLIP-MS-L10 | [d-michail/OSMGraphCLIP-MS-L10](https://huggingface.co/d-michail/OSMGraphCLIP-MS-L10) |
Code to build datasets in this format, and to train on them, is in the [osmgraphclip](https://github.com/d-michail/osmgraphclip) repo (`create_dataset.py`, `create_multiscale_dataset.py`, `create_graphs.py`, `train.py`).
## Subsets
The dataset is split into two location sets, matching the two location CSVs in the code repo:
| Subset | Locations | Source | Samples with no OSM data |
|---|---|---|---|
| `satclip_ms/` | 100,000 | `data/satclip_locations.csv` — primary location set | 1,076 |
| `h3_ms/` | 99,260 | `data/h3_locations.csv` — globally-diverse H3-sampled locations | 645 |
Each subset is independent and has the same internal layout.
## Repo layout
```
{h3_ms,satclip_ms}/
├── metadata.json # generation config for this subset (see below)
├── dataset.db # SQLite index (see below)
├── graphs.zip-parts/ # sharded graphs/ folder (~1 GiB zip shards)
│ ├── graphs-000.zip
│ ├── graphs-001.zip
│ └── ...
└── bands.zip-parts/ # sharded bands/ folder (~1 GiB zip shards)
├── bands-000.zip
└── ...
```
The raw `graphs/` and `bands/` folders are **not** stored directly in the repo (hundreds of thousands of small files each — unfriendly to git/HF). They are shipped as a sequence of zip shards instead. Each shard stores entries as `<subfolder>/<filename>`, so unzipping **every** shard for a given subset/subfolder combo into that subset's root directory reconstructs the original folder exactly, with no overlap between shards.
### Reconstructing `graphs/` and `bands/`
Use `unpack_shards.py` from this repo:
```bash
python3 unpack_shards.py h3_ms satclip_ms
```
This walks the given root(s), finds every `*.zip-parts/` directory, and unzips all shards inside it into the parent directory — reconstructing `h3_ms/graphs/`, `h3_ms/bands/`, `satclip_ms/graphs/`, `satclip_ms/bands/`. It's safe to re-run.
## `graphs/` contents
For each location, identified by an integer id `<id>`:
- `osm_<id>_graph.pkl` — a pickled [`torch_geometric.data.HeteroData`](https://pytorch-geometric.readthedocs.io/) object: the heterogeneous OSM graph with node types `polygon` (392-dim features), `line` (390-dim), `point` (386-dim), and all 9 directed edge-type combinations between them (`edge_index` + `edge_attr`). Node features are SBERT (`all-MiniLM-L6-v2`, 384-dim) embeddings of OSM tags augmented with per-type geometric attributes. Built with the GeoLink-derived `osm_to_graph.py` pipeline (`graph_method: geolink`).
- `osm_<id>_{point,linestring,multilinestring,polygon,multipolygon}.geojson.gz` — the raw gzipped OSM GeoJSON geometries (with tags) that the graph for that location was built from. Not every geometry type is present for every location.
- `osm_<id>.nodata` — present instead of the geojson files when no OSM data was found in the location's bounding box. The corresponding graph is still written (an empty `HeteroData`, `method = "zero"` in `dataset.db`), so `<id>` always has a valid graph pickle — `.nodata` just flags "empty, not missing/corrupted".
## `bands/` contents
- `osm_<id>_bands.npz` — multiscale concentric-ring band features at radii `[2000, 10000, 20000]` meters (see `band_radii_m` in `metadata.json`), keyed by:
- `band_radii` — the 3 radii, in meters
- `spatial_features` `(3, 47)` + `spatial_feature_names` — per-band aggregate spatial statistics
- `subbin_spatial` `(3, 2, 16)` + `subbin_feature_names` — per-band, per-subbin (inner/outer half of the ring) spatial statistics
- `sector_spatial` `(3, 4, 11)` + `sector_feature_names` — per-band, per-sector (quadrant) spatial statistics
- `global_embeddings` `(3, 384)`, `subbin_embeddings` `(3, 2, 384)`, `sector_embeddings` `(3, 4, 384)` — SBERT embeddings of OSM tags aggregated at the whole-band / subbin / sector level
These give the graph encoder multiscale context beyond the single bounding box used for the main graph.
## `dataset.db`
A SQLite database indexing every location by id, with three tables (same `id`s line up across tables and against the `osm_<id>_*` filenames):
- **`downloads`**: `lat`, `lon`, `bbox_size`, `geojson_prefix` (the `osm_<id>` prefix), `timestamp` — one row per raw OSM download.
- **`graphs`**: `lat`, `lon`, `bbox_size`, `graph_pickle` (filename), `method` (`geolink` or `zero`), `timestamp` — one row per built graph.
- **`band_features`**: `lat`, `lon`, `bands_path` (filename), `band_radii`, `timestamp` — one row per band-feature file.
## `metadata.json`
Generation config shared by every sample in the subset:
```json
{
"bbox_size_m": 1000,
"band_radii_m": [2000.0, 10000.0, 20000.0],
"location_source": "data/h3_locations.csv", // or data/satclip_locations.csv
"tagw_path": "data/all_tags30_frequency1.json",
"embedding_backend": "sbert",
"graph_method": "geolink"
}
```
## Citation
```bibtex
@misc{michail2026osmgraphcliplearninggloballocation,
title={OSMGraphCLIP: Learning Global Location Representations from OpenStreetMap Graphs},
author={Dimitrios Michail and Eleni Saka and Ioannis Giannopoulos and Ioannis Papoutsis},
year={2026},
eprint={2606.08046},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2606.08046},
}
```
## License and acknowledgements
Contains data from [OpenStreetMap](https://www.openstreetmap.org/copyright), © OpenStreetMap contributors, available under the [Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/).