d-michail commited on
Commit
0e2b470
·
1 Parent(s): 9a80bc0

Initial version

Browse files
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ *.db filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,131 @@
1
  ---
2
  license: odbl
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: odbl
3
+ pretty_name: OSMGraphCLIP-MS training dataset
4
+ tags:
5
+ - openstreetmap
6
+ - geospatial
7
+ - graph
8
+ - location-encoding
9
+ - remote-sensing
10
+ - contrastive-learning
11
+ - clip
12
+ size_categories:
13
+ - 100K<n<1M
14
  ---
15
+
16
+ # OSMGraphCLIP-MS
17
+
18
+ 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)).
19
+
20
+ It contains ~200k globally-diverse `(lat, lon)` locations, and for each location:
21
+
22
+ - a **heterogeneous OSM graph** (points, lines, polygons — roads, buildings, land use, POIs — with SBERT node features), and
23
+ - **multiscale concentric-ring "band" features** summarizing OSM content in rings around the location at multiple radii.
24
+
25
+ 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:
26
+
27
+ | Model | HuggingFace |
28
+ |---|---|
29
+ | OSMGraphCLIP-MS-L40 | [d-michail/OSMGraphCLIP-MS-L40](https://huggingface.co/d-michail/OSMGraphCLIP-MS-L40) |
30
+ | OSMGraphCLIP-MS-L10 | [d-michail/OSMGraphCLIP-MS-L10](https://huggingface.co/d-michail/OSMGraphCLIP-MS-L10) |
31
+
32
+ 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`).
33
+
34
+ ## Subsets
35
+
36
+ The dataset is split into two location sets, matching the two location CSVs in the code repo:
37
+
38
+ | Subset | Locations | Source | Samples with no OSM data |
39
+ |---|---|---|---|
40
+ | `satclip_ms/` | 100,000 | `data/satclip_locations.csv` — primary location set | 1,076 |
41
+ | `h3_ms/` | 99,260 | `data/h3_locations.csv` — globally-diverse H3-sampled locations | 645 |
42
+
43
+ Each subset is independent and has the same internal layout.
44
+
45
+ ## Repo layout
46
+
47
+ ```
48
+ {h3_ms,satclip_ms}/
49
+ ├── metadata.json # generation config for this subset (see below)
50
+ ├── dataset.db # SQLite index (see below)
51
+ ├── graphs.zip-parts/ # sharded graphs/ folder (~1 GiB zip shards)
52
+ │ ├── graphs-000.zip
53
+ │ ├── graphs-001.zip
54
+ │ └── ...
55
+ └── bands.zip-parts/ # sharded bands/ folder (~1 GiB zip shards)
56
+ ├── bands-000.zip
57
+ └── ...
58
+ ```
59
+
60
+ 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.
61
+
62
+ ### Reconstructing `graphs/` and `bands/`
63
+
64
+ Use `unpack_shards.py` from this repo:
65
+
66
+ ```bash
67
+ python3 unpack_shards.py h3_ms satclip_ms
68
+ ```
69
+
70
+ 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.
71
+
72
+ ## `graphs/` contents
73
+
74
+ For each location, identified by an integer id `<id>`:
75
+
76
+ - `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`).
77
+ - `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.
78
+ - `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".
79
+
80
+ ## `bands/` contents
81
+
82
+ - `osm_<id>_bands.npz` — multiscale concentric-ring band features at radii `[2000, 10000, 20000]` meters (see `band_radii_m` in `metadata.json`), keyed by:
83
+ - `band_radii` — the 3 radii, in meters
84
+ - `spatial_features` `(3, 47)` + `spatial_feature_names` — per-band aggregate spatial statistics
85
+ - `subbin_spatial` `(3, 2, 16)` + `subbin_feature_names` — per-band, per-subbin (inner/outer half of the ring) spatial statistics
86
+ - `sector_spatial` `(3, 4, 11)` + `sector_feature_names` — per-band, per-sector (quadrant) spatial statistics
87
+ - `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
88
+
89
+ These give the graph encoder multiscale context beyond the single bounding box used for the main graph.
90
+
91
+ ## `dataset.db`
92
+
93
+ A SQLite database indexing every location by id, with three tables (same `id`s line up across tables and against the `osm_<id>_*` filenames):
94
+
95
+ - **`downloads`**: `lat`, `lon`, `bbox_size`, `geojson_prefix` (the `osm_<id>` prefix), `timestamp` — one row per raw OSM download.
96
+ - **`graphs`**: `lat`, `lon`, `bbox_size`, `graph_pickle` (filename), `method` (`geolink` or `zero`), `timestamp` — one row per built graph.
97
+ - **`band_features`**: `lat`, `lon`, `bands_path` (filename), `band_radii`, `timestamp` — one row per band-feature file.
98
+
99
+ ## `metadata.json`
100
+
101
+ Generation config shared by every sample in the subset:
102
+
103
+ ```json
104
+ {
105
+ "bbox_size_m": 1000,
106
+ "band_radii_m": [2000.0, 10000.0, 20000.0],
107
+ "location_source": "data/h3_locations.csv", // or data/satclip_locations.csv
108
+ "tagw_path": "data/all_tags30_frequency1.json",
109
+ "embedding_backend": "sbert",
110
+ "graph_method": "geolink"
111
+ }
112
+ ```
113
+
114
+ ## Citation
115
+
116
+ ```bibtex
117
+ @misc{michail2026osmgraphcliplearninggloballocation,
118
+ title={OSMGraphCLIP: Learning Global Location Representations from OpenStreetMap Graphs},
119
+ author={Dimitrios Michail and Eleni Saka and Ioannis Giannopoulos and Ioannis Papoutsis},
120
+ year={2026},
121
+ eprint={2606.08046},
122
+ archivePrefix={arXiv},
123
+ primaryClass={cs.AI},
124
+ url={https://arxiv.org/abs/2606.08046},
125
+ }
126
+ ```
127
+
128
+ ## License and acknowledgements
129
+
130
+ Contains data from [OpenStreetMap](https://www.openstreetmap.org/copyright), © OpenStreetMap contributors, available under the [Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/).
131
+
h3_ms/bands.zip-parts/bands-000.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b3daea70efbc6ea0750600975001c21f3da2eb345e2b9d2bc0e96224110a223
3
+ size 1070318849
h3_ms/bands.zip-parts/bands-001.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e92de4a49183e2c01300b97ecd609faf2ca5e7673ca2e3dbce904eb5e16a13e
3
+ size 855059006
h3_ms/dataset.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdb172fd32e41ee3dd2740a660bb574f1f7d2ce2329ca04632f311fecc3b71d9
3
+ size 45801472
h3_ms/graphs.zip-parts/graphs-000.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0083b136b8dc169508285cbd6f9d7ce031e5cd8dac1b540690771bbdfa0b5467
3
+ size 1808432659
h3_ms/graphs.zip-parts/graphs-001.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7a7d70859745e4ac688e6455d1884905bd192c8ea0e23b8cf88c5814b7d924f
3
+ size 907336265
h3_ms/graphs.zip-parts/graphs-002.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4de4e15f1b0a138a96975716e17a76d8436c02b1e624cf87cea265c92c49ba84
3
+ size 815730196
h3_ms/graphs.zip-parts/graphs-003.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65a5750aba0b916a244f4daa57c6726a0dfb0cbc9831de100cec5b955018c921
3
+ size 795533092
h3_ms/graphs.zip-parts/graphs-004.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cecd630cdc7ce6b97500e6b1821b5a4f3fe924b913e43c8d95fd19bbdcc2f551
3
+ size 825611290
h3_ms/graphs.zip-parts/graphs-005.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1960943ff9199997c87185cf2def5bac60f58fdac80ded0ec25d75d6da9c681f
3
+ size 966445175
h3_ms/graphs.zip-parts/graphs-006.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b09e46c0eea068653c677d4235f825d69b05517d5d38522b507f5e1ff50f37e
3
+ size 251899868
h3_ms/metadata.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox_size_m": 1000,
3
+ "band_radii_m": [
4
+ 2000.0,
5
+ 10000.0,
6
+ 20000.0
7
+ ],
8
+ "location_source": "data/h3_locations/h3_locations.csv",
9
+ "embedding_model": null,
10
+ "tagw_path": "data/all_tags30_frequency1.json",
11
+ "embedding_backend": "sbert",
12
+ "graph_method": "geolink"
13
+ }
satclip_ms/bands.zip-parts/bands-000.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbce0f42c921c300b9334a5441e95a4ef2a6e8938ee11a504fc6238bec7f92c9
3
+ size 1070951783
satclip_ms/bands.zip-parts/bands-001.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0de9a771e631d443f517901e29162232a93e54dad52f79c91d6bfcb55ef669a
3
+ size 637116873
satclip_ms/dataset.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:912850a501105b7fe87e6a21a33ce7db1e67acf91b34dc565c511d296d4d63b0
3
+ size 46116864
satclip_ms/graphs.zip-parts/graphs-000.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5b42b86cb9d4a34beeec9f091cdd152e919b73a02aae7f4b61d11d319d70e5e
3
+ size 953272123
satclip_ms/graphs.zip-parts/graphs-001.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8c0b857fcd1817690bd6d4acb1b9b28af7c45a2d815ee79d3dd19cc6797dde6
3
+ size 943843737
satclip_ms/graphs.zip-parts/graphs-002.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:864ef49fa0b424da0cd5fe684d26af2ae2fa31912c0290e0f73c8238b3a80b2f
3
+ size 611255788
satclip_ms/metadata.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox_size_m": 1000,
3
+ "band_radii_m": [
4
+ 2000.0,
5
+ 10000.0,
6
+ 20000.0
7
+ ],
8
+ "location_source": "data/satclip_locations.csv",
9
+ "embedding_model": null,
10
+ "tagw_path": "data/all_tags30_frequency1.json",
11
+ "embedding_backend": "sbert",
12
+ "graph_method": "geolink"
13
+ }
unpack_shards.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Reassemble sharded folders produced by make_shards.py.
3
+
4
+ Finds every "<name>.zip-parts/" directory under the given root(s) and
5
+ unzips all shard zips inside it into the parent directory, reconstructing
6
+ the original "<name>/" folder. Safe to re-run (existing files are
7
+ overwritten with -o).
8
+
9
+ Usage:
10
+ python3 unpack_shards.py [root ...]
11
+
12
+ With no arguments, searches the current directory.
13
+ """
14
+ import glob
15
+ import os
16
+ import subprocess
17
+ import sys
18
+
19
+
20
+ def find_zip_parts_dirs(root):
21
+ matches = []
22
+ for dirpath, dirnames, _ in os.walk(root):
23
+ for d in list(dirnames):
24
+ if d.endswith(".zip-parts"):
25
+ matches.append(os.path.join(dirpath, d))
26
+ dirnames.remove(d) # no need to descend into it
27
+ return sorted(matches)
28
+
29
+
30
+ def unpack(zip_parts_dir):
31
+ dest = os.path.dirname(zip_parts_dir)
32
+ shards = sorted(glob.glob(os.path.join(zip_parts_dir, "*.zip")))
33
+ if not shards:
34
+ print(f" no shards found in {zip_parts_dir}, skipping")
35
+ return
36
+ name = os.path.basename(zip_parts_dir)[: -len(".zip-parts")]
37
+ print(f"=== {zip_parts_dir} -> {os.path.join(dest, name)}/ ({len(shards)} shard(s)) ===")
38
+ for shard in shards:
39
+ print(f" extracting {os.path.basename(shard)}")
40
+ subprocess.run(["unzip", "-oq", shard, "-d", dest], check=True)
41
+ print(" done")
42
+
43
+
44
+ def main():
45
+ roots = sys.argv[1:] or ["."]
46
+ zip_parts_dirs = []
47
+ for root in roots:
48
+ zip_parts_dirs.extend(find_zip_parts_dirs(root))
49
+
50
+ if not zip_parts_dirs:
51
+ print("No *.zip-parts directories found.")
52
+ return
53
+
54
+ for zip_parts_dir in zip_parts_dirs:
55
+ unpack(zip_parts_dir)
56
+
57
+
58
+ if __name__ == "__main__":
59
+ main()