Datasets:
docs: shorten V1 dataset reference
Browse files
README.md
CHANGED
|
@@ -1,40 +1,79 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
* **Hugging Face dataset**: <https://huggingface.co/datasets/NoeFlandre/osm-polygon-wikidata-only>
|
| 13 |
-
* **V2 Hugging Face dataset**: <https://huggingface.co/datasets/NoeFlandre/osm-polygon-wikidata-and-wikipedia>
|
| 14 |
-
* **Documentation**: <https://noeflandre.github.io/osm-polygon-wikidata-only/>
|
| 15 |
-
* **Maintainer**: Noé Flandre
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
`wikipedia=*` tags without changing V1.
|
| 25 |
|
| 26 |
## Trackio snapshot
|
| 27 |
|
| 28 |
-
[View the dataset presentation](https://noeflandre.github.io/osm-polygon-wikidata-only/presentations/dataset.html)
|
| 29 |
-
for a visual overview of the published tables and geographic coverage.
|
| 30 |
-
[View the codebase presentation](https://noeflandre.github.io/osm-polygon-wikidata-only/presentations/codebase.html)
|
| 31 |
-
for a visual overview of the architecture and implementation.
|
| 32 |
|
| 33 |
-
The finished dataset is recorded in the single public Trackio run
|
| 34 |
-
[`final-dataset-snapshot`](https://huggingface.co/spaces/NoeFlandre/osm-polygon-wikidata-only-trackio).
|
| 35 |
-
It contains exactly three plots: a text-coverage funnel, the top ten Wikipedia
|
| 36 |
-
languages plus `Other languages`, and dataset composition on a logarithmic scale.
|
| 37 |
-
The run is a static snapshot with no pipeline timeline.
|
| 38 |
|
| 39 |
| Snapshot metric | Value |
|
| 40 |
| --- | ---: |
|
|
@@ -50,676 +89,457 @@ The run is a static snapshot with no pipeline timeline.
|
|
| 50 |
| Polygon/link-table storage | 9.9 GB |
|
| 51 |
| Total Parquet storage | 19.2 GB |
|
| 52 |
|
| 53 |
-
The funnel's language thresholds use the canonical Wikipedia polygon fields.
|
| 54 |
-
Wikivoyage is included in the combined document, word, and dataset-composition totals.
|
| 55 |
-
|
| 56 |
-
Documentation: [architecture](docs/architecture.md) ·
|
| 57 |
-
[supported Python API](docs/api.md) · [development](docs/development.md) ·
|
| 58 |
-
[contributing](CONTRIBUTING.md) · [security](SECURITY.md)
|
| 59 |
-
|
| 60 |
-
---
|
| 61 |
-
|
| 62 |
-
## What this project does
|
| 63 |
-
|
| 64 |
-
1. Reads Geofabrik `.osm.pbf` files (country / region extracts).
|
| 65 |
-
2. Keeps only the polygonal elements:
|
| 66 |
-
* **Closed ways** carrying a non-empty `wikidata=*` tag.
|
| 67 |
-
* **Multipolygon relations** carrying a non-empty `wikidata=*` tag.
|
| 68 |
-
3. Computes geometry metadata per polygon (centroid via
|
| 69 |
-
equirectangular projection, area in m² and km², bbox, area bucket,
|
| 70 |
-
primary OSM tag).
|
| 71 |
-
4. Looks up the polygons' Wikidata QIDs (entity, sitelinks,
|
| 72 |
-
descriptions) and then fetches each linked Wikipedia article
|
| 73 |
-
(lead text, full plain text, page/revision ID, license,
|
| 74 |
-
attribution).
|
| 75 |
-
5. Publishes the canonical region tables on the Hugging Face Hub:
|
| 76 |
-
* `polygons/<stem>.parquet` — one row per polygon.
|
| 77 |
-
* `wikipedia/documents/<stem>.parquet` — one row per unique Wikipedia article revision.
|
| 78 |
-
* `polygon_articles/<stem>.parquet` — unified many-to-many
|
| 79 |
-
polygon↔document links for Wikipedia and Wikivoyage.
|
| 80 |
-
* `manifests/processed_pbfs.json` — aggregate stats per source PBF.
|
| 81 |
-
6. Adds text and fact tables without reprocessing completed PBFs:
|
| 82 |
-
* `wikipedia/sections/<stem>.parquet` — section-level Wikipedia text.
|
| 83 |
-
* `wikivoyage/documents/<stem>.parquet` — full Wikivoyage documents.
|
| 84 |
-
* `wikivoyage/sections/<stem>.parquet` — section-level Wikivoyage text.
|
| 85 |
-
* `wikidata/facts/<stem>.parquet` — structured claims for polygon entities.
|
| 86 |
-
7. Publishes one frozen Trackio run with static dataset metrics and three plots.
|
| 87 |
-
|
| 88 |
-
V2 is an explicit, isolated workflow. It starts from finalized V1 artifacts,
|
| 89 |
-
scans each source PBF for direct Wikipedia tags, reuses matching V1 documents,
|
| 90 |
-
fetches only missing direct pages, and writes under `processed_v2/`. It uses a
|
| 91 |
-
unified `polygon_document_links/` table with `link_sources` provenance and
|
| 92 |
-
publishes to the separate V2 dataset above. V2 also writes
|
| 93 |
-
`wikipedia/sections/<stem>.parquet` with the exact V1 section schema, reusing
|
| 94 |
-
existing V1 rows and fetching only missing Wikipedia revisions. V1 files and
|
| 95 |
-
the default workflow are never rewritten by a V2 run. V2 keeps a resumable
|
| 96 |
-
reuse index in `cache/v2/v1-index/`; completed Parquet row groups are reused
|
| 97 |
-
after an interruption or later restart. Extraction batches and completed direct
|
| 98 |
-
Wikipedia results and section parses are checkpointed under
|
| 99 |
-
`cache/v2/checkpoints/` and removed only after the region reaches its final
|
| 100 |
-
local commit. A restart rescans at most the source PBF because libosmium does
|
| 101 |
-
not expose a portable byte offset, while already saved extraction and fetch
|
| 102 |
-
work is reused and never published until final reconciliation.
|
| 103 |
-
|
| 104 |
-
The generated dataset is published on Hugging Face. Local processing inputs,
|
| 105 |
-
intermediate files, and caches use a configurable data root outside the source
|
| 106 |
-
checkout.
|
| 107 |
-
|
| 108 |
-
---
|
| 109 |
-
|
| 110 |
-
## Repository layout
|
| 111 |
-
|
| 112 |
-
```
|
| 113 |
-
.
|
| 114 |
-
├── src/osm_polygon_wikidata_only/
|
| 115 |
-
│ ├── __init__.py
|
| 116 |
-
│ ├── augmentation/ # Wikipedia/Wikivoyage sections and Wikidata facts
|
| 117 |
-
│ ├── cli/ # Argument parsing and command adapters
|
| 118 |
-
│ ├── cli/_sync/ # Fail-closed sync publication/retirement helpers
|
| 119 |
-
│ ├── config/ # DataRoot paths and runtime Settings
|
| 120 |
-
│ ├── domain/ # Pure models, schemas, geometry, and identifiers
|
| 121 |
-
│ ├── enrichment/wikidata/ # Wikidata models, parsing, cache, and transport
|
| 122 |
-
│ ├── enrichment/wikipedia/ # Wikipedia models, parsing, cache, and transport
|
| 123 |
-
│ ├── hf/_dataset_stats/ # Dataset-card statistics internals
|
| 124 |
-
│ ├── hf/_geographic/ # Deterministic H3 visualizations
|
| 125 |
-
│ ├── hf/_publication/ # Publication artifact models and validation
|
| 126 |
-
│ ├── hf/_uploader/ # Hub authorization and upload operations
|
| 127 |
-
│ ├── io/ # PBF, Parquet, manifests, cache, and atomic I/O
|
| 128 |
-
│ ├── pipeline/_link_migration/ # Conversion and journaled migration helpers
|
| 129 |
-
│ ├── pipeline/_wikidata_recovery/ # Audited, resumable repair internals
|
| 130 |
-
│ ├── v2/ # Isolated Wikipedia-tag dataset contract and runner
|
| 131 |
-
│ └── utils/ # JSON, logging, retries, time, and scheduling
|
| 132 |
-
├── tests/ # Unit, integration, contract, and golden tests
|
| 133 |
-
��── pyproject.toml # Build, dev dependencies, Ruff/ty/pytest config
|
| 134 |
-
└── README.md
|
| 135 |
-
```
|
| 136 |
-
|
| 137 |
-
Each top-level sub-package has its own `__init__.py` and a tightly
|
| 138 |
-
focused public API. Cross-package imports go through dotted paths.
|
| 139 |
-
|
| 140 |
-
---
|
| 141 |
-
|
| 142 |
-
## Installation
|
| 143 |
-
|
| 144 |
-
Requires Python 3.12+ and [`uv`](https://docs.astral.sh/uv/).
|
| 145 |
-
|
| 146 |
-
```bash
|
| 147 |
-
git clone https://github.com/NoeFlandre/osm-polygon-wikidata-only.git
|
| 148 |
-
cd osm-polygon-wikidata-only
|
| 149 |
-
uv sync
|
| 150 |
-
```
|
| 151 |
-
|
| 152 |
-
This installs all runtime and development dependencies into a managed
|
| 153 |
-
`.venv`:
|
| 154 |
-
|
| 155 |
-
| Runtime | Purpose |
|
| 156 |
-
|---|---|
|
| 157 |
-
| `osmium` | Streaming OSM PBF parser |
|
| 158 |
-
| `datasets` | Hugging Face dataset utilities |
|
| 159 |
-
| `huggingface-hub` | HF Hub client |
|
| 160 |
-
| `pyarrow` | Parquet serialization |
|
| 161 |
-
| `typer`, `rich`, `tqdm` | Read-only operator audit CLI, structured reports, and interactive progress |
|
| 162 |
-
|
| 163 |
-
| Dev | Purpose |
|
| 164 |
-
|---|---|
|
| 165 |
-
| `pytest`, `pytest-cov` | Tests |
|
| 166 |
-
| `ruff` | Lint + format |
|
| 167 |
-
| `ty` | Type-check production code and maintained scripts |
|
| 168 |
-
| `pre-commit` | Fast commit-time quality checks |
|
| 169 |
-
| [`just`](https://just.systems/) | Shared local and CI command runner |
|
| 170 |
-
|
| 171 |
-
---
|
| 172 |
-
|
| 173 |
-
## Local data root
|
| 174 |
-
|
| 175 |
-
All PBF inputs, intermediate outputs, Hugging Face caches, and local
|
| 176 |
-
parquet/manifest files live under one operator-selected **data root**.
|
| 177 |
-
|
| 178 |
-
Resolution order:
|
| 179 |
-
|
| 180 |
-
1. `--data-root <path>` CLI flag.
|
| 181 |
-
2. `OSM_POLYGON_DATA_ROOT` environment variable.
|
| 182 |
-
|
| 183 |
-
A data root is required, must already exist, and is rejected when it points
|
| 184 |
-
inside the source checkout. There is no silent fallback.
|
| 185 |
-
|
| 186 |
-
Default sub-directories under the data root:
|
| 187 |
-
|
| 188 |
-
| Sub-directory | Purpose |
|
| 189 |
-
|---|---|
|
| 190 |
-
| `raw/` | Geofabrik `.osm.pbf` files (input) |
|
| 191 |
-
| `processed/polygons/` | Written `polygons/<stem>.parquet` files |
|
| 192 |
-
| `processed/articles/` | Local legacy staging files, retained only until their verified canonical publication succeeds |
|
| 193 |
-
| `processed/wikipedia/documents/` | Canonical Wikipedia documents |
|
| 194 |
-
| `processed/polygon_articles/` | Written `polygon_articles/<stem>.parquet` files |
|
| 195 |
-
| `processed/manifests/` | `processed_pbfs.json` aggregate manifest |
|
| 196 |
-
| `logs/` | Reserved for pipeline logs |
|
| 197 |
-
| `hf_cache/` | Hugging Face client-side cache |
|
| 198 |
-
| `cache/wikidata/`, `cache/wikipedia/` | Per-call JSON cache |
|
| 199 |
-
| `cache/` | Shared cache root |
|
| 200 |
-
|
| 201 |
-
Set the data root for a session:
|
| 202 |
-
|
| 203 |
-
```bash
|
| 204 |
-
export OSM_POLYGON_DATA_ROOT=/path/to/osm-polygon-data
|
| 205 |
-
```
|
| 206 |
-
|
| 207 |
-
---
|
| 208 |
-
|
| 209 |
-
## Usage
|
| 210 |
-
|
| 211 |
-
After `uv sync`, the processing and augmentation commands are:
|
| 212 |
-
|
| 213 |
-
```bash
|
| 214 |
-
uv run osm-polygon-wikidata-only sync-dir <dir> [--options]
|
| 215 |
-
uv run osm-polygon-wikidata-only process-pbf <input.pbf> [--options]
|
| 216 |
-
uv run osm-polygon-wikidata-only process-dir <dir> [--options]
|
| 217 |
-
uv run osm-polygon-wikidata-only augment-region <stem> [--options]
|
| 218 |
-
uv run osm-polygon-wikidata-only augment-dir [--options]
|
| 219 |
-
uv run osm-polygon-wikidata-only-trackio [--data-root <path>]
|
| 220 |
-
```
|
| 221 |
-
|
| 222 |
-
### Common options
|
| 223 |
-
|
| 224 |
-
| Flag | Purpose |
|
| 225 |
-
|---|---|
|
| 226 |
-
| `--data-root <path>` | Override the resolved external data root |
|
| 227 |
-
| `--repo-id <org/name>` | Target Hugging Face repo (default `NoeFlandre/osm-polygon-wikidata-only`) |
|
| 228 |
-
| `--user-agent <ua>` | Override Wikimedia User-Agent (default identifies this project) |
|
| 229 |
-
| `--languages en,fr,...` | Explicitly narrow the default all-language sitelink set |
|
| 230 |
-
| `--all-languages` | Explicit compatibility alias for the all-language default |
|
| 231 |
-
| `--no-full-text` | Fetch only the lead section, not the full article |
|
| 232 |
-
| `--max-articles-per-qid <n>` | Explicitly cap articles per QID (default: no cap) |
|
| 233 |
-
| `--enrichment-batch-size <n>` | Maximum QIDs/titles per API batch (default `50`) |
|
| 234 |
-
| `--enrichment-site-workers <n>` | Concurrent Wikipedia batch jobs (default `8`) |
|
| 235 |
-
| `--limit <n>` | Process only the first N polygons per PBF |
|
| 236 |
-
| `--skip-existing` | Skip PBFs already listed in the manifest |
|
| 237 |
-
| `--force` | Re-process even when `--skip-existing` applies |
|
| 238 |
-
| `--push` | Upload produced artifacts to the Hub |
|
| 239 |
-
| `--upload-threads <n>` | Concurrent transfer workers in the atomic Hub commit (default `5`) |
|
| 240 |
-
| `--commit-message <msg>` | Custom git commit message for the push |
|
| 241 |
-
| `--dry-run` | Use a stub HF client (records calls without uploading) |
|
| 242 |
-
| `--log-level <level>` | `DEBUG` / `INFO` / `WARNING` / `ERROR` |
|
| 243 |
-
| `--dataset-version v1|v2` | Select the sync contract; V2 is opt-in and publishes to its separate Hub dataset |
|
| 244 |
-
|
| 245 |
-
### Examples
|
| 246 |
-
|
| 247 |
-
Process one PBF and write 3 parquet files + manifest locally:
|
| 248 |
-
|
| 249 |
-
```bash
|
| 250 |
-
uv run osm-polygon-wikidata-only process-pbf ~/pbfs/monaco-latest.osm.pbf
|
| 251 |
-
```
|
| 252 |
-
|
| 253 |
-
Push the result to the Hub with a stub client (no network):
|
| 254 |
-
|
| 255 |
-
```bash
|
| 256 |
-
uv run osm-polygon-wikidata-only process-pbf monaco-latest.osm.pbf --push --dry-run
|
| 257 |
-
```
|
| 258 |
-
|
| 259 |
-
Process every PBF under `<data-root>/raw/`, fetch only English and
|
| 260 |
-
French Wikipedia, skip already-processed:
|
| 261 |
-
|
| 262 |
-
```bash
|
| 263 |
-
uv run osm-polygon-wikidata-only process-dir \
|
| 264 |
-
~/pbfs/ \
|
| 265 |
-
--languages en,fr \
|
| 266 |
-
--skip-existing
|
| 267 |
-
```
|
| 268 |
-
|
| 269 |
-
Build the isolated V2 dataset. This keeps V1 artifacts intact, reuses their
|
| 270 |
-
finalized documents and sidecars, and fetches only direct Wikipedia-tag pages
|
| 271 |
-
that are not already present in V1:
|
| 272 |
-
|
| 273 |
-
```bash
|
| 274 |
-
uv run osm-polygon-wikidata-only sync-dir \
|
| 275 |
-
"$OSM_POLYGON_DATA_ROOT/raw" \
|
| 276 |
-
--dataset-version v2 \
|
| 277 |
-
--skip-existing \
|
| 278 |
-
--push
|
| 279 |
-
```
|
| 280 |
-
|
| 281 |
-
V2 local artifacts are written below `processed_v2/`; its request cache,
|
| 282 |
-
resumable V1 reuse index, and restart checkpoints are below `cache/v2/`. The index is built one shard at
|
| 283 |
-
a time while PBF extraction starts, and each Parquet row group is checkpointed
|
| 284 |
-
across restarts. Its SQLite storage setup also runs in the background, so it
|
| 285 |
-
does not delay extraction. A direct page that is not yet found may be fetched
|
| 286 |
-
while the index continues. Once indexing finishes, a V1 match is preferred;
|
| 287 |
-
only a page still absent from V1 keeps the fetched result. Both locations use
|
| 288 |
-
the configured data root, so stopping and restarting the command is safe.
|
| 289 |
-
Use `--force` only when deliberately rebuilding a V2 region.
|
| 290 |
-
|
| 291 |
-
### Wikimedia Bot Password authentication
|
| 292 |
-
|
| 293 |
-
Long production runs should authenticate their read-only API requests with a
|
| 294 |
-
Wikimedia Bot Password. Authentication identifies the pipeline to Wikimedia
|
| 295 |
-
and lets the account receive its applicable API request tier. It does not grant
|
| 296 |
-
this project permission to edit Wikimedia.
|
| 297 |
-
|
| 298 |
-
Create the credentials once:
|
| 299 |
-
|
| 300 |
-
1. Sign in to the Wikimedia account that will operate the pipeline.
|
| 301 |
-
2. Open [Meta-Wiki Special:BotPasswords](https://meta.wikimedia.org/wiki/Special:BotPasswords).
|
| 302 |
-
3. Enter a descriptive bot name such as `osm-polygon-pipeline`.
|
| 303 |
-
4. Select **Basic rights**, which are required for API reading. Leave editing,
|
| 304 |
-
page creation, uploading, and administration grants disabled; this pipeline
|
| 305 |
-
only reads public API data.
|
| 306 |
-
5. Create the Bot Password and copy both generated values immediately. The
|
| 307 |
-
username includes a suffix, for example `AccountName@osm-polygon-pipeline`;
|
| 308 |
-
use the complete generated username, not the main account username.
|
| 309 |
-
|
| 310 |
-
Export them into the current terminal session. Reading the password silently
|
| 311 |
-
keeps it out of shell history:
|
| 312 |
-
|
| 313 |
-
```bash
|
| 314 |
-
export WIKIMEDIA_BOT_USERNAME='AccountName@osm-polygon-pipeline'
|
| 315 |
-
read -rs WIKIMEDIA_BOT_PASSWORD
|
| 316 |
-
export WIKIMEDIA_BOT_PASSWORD
|
| 317 |
-
```
|
| 318 |
-
|
| 319 |
-
Paste the generated password at the silent prompt and press Enter. Do not commit
|
| 320 |
-
the password, add it to a checked-in `.env` file, paste it into an issue, or use
|
| 321 |
-
the main Wikimedia account password. The process retains it only in memory.
|
| 322 |
|
| 323 |
-
|
| 324 |
-
1,200-request-per-minute budget with one shared scheduler and at most eight requests in flight
|
| 325 |
-
(anonymous runs default to three). To choose a different authenticated ceiling:
|
| 326 |
-
|
| 327 |
-
```bash
|
| 328 |
-
export WIKIMEDIA_REQUESTS_PER_MINUTE=600
|
| 329 |
-
```
|
| 330 |
-
|
| 331 |
-
Usually, omit this override and let the adaptive scheduler work. Wikimedia
|
| 332 |
-
determines the actual tier from the account's standing: authentication alone
|
| 333 |
-
does not guarantee a particular limit. The pipeline keeps at most eight requests
|
| 334 |
-
in flight for authenticated runs, keeps cookies domain-scoped in one bounded persistent connection pool,
|
| 335 |
-
and automatically reduces its rate when Wikimedia returns HTTP 429 with
|
| 336 |
-
`Retry-After`.
|
| 337 |
-
|
| 338 |
-
The startup log states either `anonymous` or `authenticated as <username>` and
|
| 339 |
-
the configured ceiling. The password is never logged. Authentication itself is
|
| 340 |
-
verified lazily on the first request to each Wikidata or language-Wikipedia host.
|
| 341 |
-
If only one credential variable is set, configuration stops before processing;
|
| 342 |
-
if Wikimedia rejects the pair, the first API request fails without silently
|
| 343 |
-
falling back to anonymous access.
|
| 344 |
-
|
| 345 |
-
Troubleshooting:
|
| 346 |
-
|
| 347 |
-
- If the application names a missing variable, export both variables in the same
|
| 348 |
-
terminal that launches `uv run`.
|
| 349 |
-
- If authentication is rejected, copy the complete generated bot username,
|
| 350 |
-
reset or recreate the Bot Password, and export the new values. Changing the
|
| 351 |
-
main account password can require resetting Bot Passwords.
|
| 352 |
-
- If HTTP 429 responses continue, leave the automatic cooldown in control or
|
| 353 |
-
lower `WIKIMEDIA_REQUESTS_PER_MINUTE`; do not override the concurrency limit
|
| 354 |
-
without measuring the result.
|
| 355 |
-
- To revoke access, return to
|
| 356 |
-
[Special:BotPasswords](https://meta.wikimedia.org/wiki/Special:BotPasswords)
|
| 357 |
-
and revoke the named Bot Password. Then remove the variables with
|
| 358 |
-
`unset WIKIMEDIA_BOT_USERNAME WIKIMEDIA_BOT_PASSWORD`.
|
| 359 |
-
|
| 360 |
-
The implementation follows Wikimedia's official
|
| 361 |
-
[Bot Password](https://www.mediawiki.org/wiki/Manual:Bot_passwords),
|
| 362 |
-
[API login](https://www.mediawiki.org/wiki/API:Login), and
|
| 363 |
-
[API rate-limit](https://www.mediawiki.org/wiki/Wikimedia_APIs/Rate_limits)
|
| 364 |
-
guidance.
|
| 365 |
-
|
| 366 |
-
### Resumable full-dataset command
|
| 367 |
-
|
| 368 |
-
Run this single command to reconcile the existing augmentation backlog, repair
|
| 369 |
-
remotely missing finalized artifacts without refetching them, process missing
|
| 370 |
-
PBFs, immediately augment them, and publish complete regional bundles:
|
| 371 |
-
|
| 372 |
-
```bash
|
| 373 |
-
uv run osm-polygon-wikidata-only sync-dir "$OSM_POLYGON_DATA_ROOT/raw" \
|
| 374 |
-
--skip-existing \
|
| 375 |
-
--push
|
| 376 |
-
```
|
| 377 |
-
|
| 378 |
-
`process-dir` and `augment-dir` remain available as compatibility commands, but
|
| 379 |
-
do not run them beside `sync-dir`. A data-root lock prevents duplicate unified
|
| 380 |
-
runs. Each completed region is uploaded atomically with fresh manifests and the
|
| 381 |
-
canonical dataset `README.md`. Internally the unified sync drains actions in
|
| 382 |
-
this order: RECOVERY first for finalized shards eligible for an exhaustive
|
| 383 |
-
local integrity audit (only affected QIDs are refetched and repaired transactionally),
|
| 384 |
-
then AUGMENT backlog (each call performs Wikimedia sidecar work
|
| 385 |
-
and may enqueue an atomic remote publication on success), then PUBLISH-only
|
| 386 |
-
reconciliation repairs (Wikimedia-free -- each repair reuses the already-loaded
|
| 387 |
-
local augmentation result and only enqueues a Hugging Face upload, with no
|
| 388 |
-
extraction and no Wikidata / Wikipedia / Wikivoyage calls), then new core
|
| 389 |
-
PROCESS work (the runner may prefetch the next PBF concurrently while
|
| 390 |
-
enriching the current region), then COMPLETE / no-op states. Maps and the
|
| 391 |
-
README are only reported "refreshed" after a successful core or metadata
|
| 392 |
-
publication actually refreshed them and the background upload queue has
|
| 393 |
-
drained.
|
| 394 |
-
|
| 395 |
-
The recovery audit is resumable, content-addressed, and processed one region at
|
| 396 |
-
a time. Healthy finalized regions store or reuse a receipt and continue; a
|
| 397 |
-
damaged region is repaired and published immediately before the next region is
|
| 398 |
-
audited. Stopping the command therefore preserves completed regional work,
|
| 399 |
-
while changed inputs are checked again. A malformed or unreadable finalized
|
| 400 |
-
shard fails closed instead of being silently skipped. Regions with incomplete
|
| 401 |
-
sidecars are augmented first and audited immediately afterward in the same
|
| 402 |
-
invocation. A repaired region is published atomically with its regional
|
| 403 |
-
artifacts, manifests, and dataset card. Coverage maps are regenerated only
|
| 404 |
-
when the repair changed one of their polygon, link, or document inputs.
|
| 405 |
-
Legacy Wikidata fact rows whose subject is no longer present in the region's
|
| 406 |
-
polygons are removed by that same transaction; all still-joinable facts are
|
| 407 |
-
preserved.
|
| 408 |
-
The command reports bounded local-scan and upstream-validation checkpoints with
|
| 409 |
-
elapsed time. Up to three independent validation chunks overlap under the same
|
| 410 |
-
shared request scheduler, while transient Wikimedia API states such as `maxlag`
|
| 411 |
-
remain retryable and never become cached missing entities.
|
| 412 |
-
|
| 413 |
-
Affected relationships are repaired in deterministic groups of 25 QIDs. Up to
|
| 414 |
-
three independent groups run concurrently under the same shared global and
|
| 415 |
-
per-host Wikimedia scheduler. Each completed group is stored immediately below
|
| 416 |
-
`cache/wikidata_recovery/checkpoints/<stem>/<plan-hash>/`, so an interruption
|
| 417 |
-
repeats only unfinished groups. The final regional Parquet files and manifests
|
| 418 |
-
are still replaced atomically only after every group has completed.
|
| 419 |
-
|
| 420 |
-
Known whole-file Geofabrik containment overlaps are retired safely during
|
| 421 |
-
`sync-dir --push`: retained parents receive missing sidecar rows, contained
|
| 422 |
-
child artifacts are removed remotely in one atomic commit, and local originals
|
| 423 |
-
are preserved under `quarantine/containment-v1/`. A child PBF is ignored only
|
| 424 |
-
after the durable retirement manifest records local preparation; a missing
|
| 425 |
-
parent polygon blocks retirement rather than discarding data.
|
| 426 |
-
|
| 427 |
-
To pause, stop the command with `Ctrl-C`. Run the identical command again to
|
| 428 |
-
resume: completed PBFs remain skipped, while the interrupted PBF is retried
|
| 429 |
-
because it has no completed manifest entry. The durable pending-publications
|
| 430 |
-
manifest and the upload-queue state files persist across restarts, so a
|
| 431 |
-
failed upload is always retryable on the next invocation. Stage timings are
|
| 432 |
-
logged for every PBF. Tune large runs only when needed with
|
| 433 |
-
`--enrichment-batch-size`, `--enrichment-site-workers`, and `--upload-threads`.
|
| 434 |
-
|
| 435 |
-
The normal command fetches full text for every valid language-Wikipedia
|
| 436 |
-
sitelink with no per-QID cap. If any expected article remains unresolved after
|
| 437 |
-
retries, that PBF is not published; rerunning resumes from successful cache
|
| 438 |
-
checkpoints. With `--push`, each locally complete PBF is queued for an atomic
|
| 439 |
-
background upload while the next PBF starts processing. Shutdown waits for the
|
| 440 |
-
queue, and unresolved uploads make the command exit nonzero and remain queued
|
| 441 |
-
for the next invocation.
|
| 442 |
-
|
| 443 |
-
Programmatic usage:
|
| 444 |
-
|
| 445 |
-
```python
|
| 446 |
-
from pathlib import Path
|
| 447 |
-
from osm_polygon_wikidata_only.config.paths import DataRoot, resolve_data_root
|
| 448 |
-
from osm_polygon_wikidata_only.config.settings import Settings
|
| 449 |
-
from osm_polygon_wikidata_only.enrichment.wikipedia_client import HttpWikipediaClient
|
| 450 |
-
from osm_polygon_wikidata_only.enrichment.wikidata_client import HttpWikidataClient
|
| 451 |
-
from osm_polygon_wikidata_only.pipeline.processor import process_pbf
|
| 452 |
-
|
| 453 |
-
data_root = resolve_data_root(repo_root=Path.cwd())
|
| 454 |
-
data_root.ensure()
|
| 455 |
-
|
| 456 |
-
settings = Settings(languages=("en", "fr"))
|
| 457 |
-
wd = HttpWikidataClient(settings)
|
| 458 |
-
wiki = HttpWikipediaClient(settings)
|
| 459 |
-
|
| 460 |
-
result = process_pbf(
|
| 461 |
-
Path("monaco-latest.osm.pbf"),
|
| 462 |
-
data_root=data_root,
|
| 463 |
-
wikidata_client=wd,
|
| 464 |
-
wikipedia_client=wiki,
|
| 465 |
-
settings=settings,
|
| 466 |
-
)
|
| 467 |
-
print(result.polygon_count, "polygons")
|
| 468 |
-
```
|
| 469 |
-
|
| 470 |
-
## Reliability and performance behavior
|
| 471 |
-
|
| 472 |
-
The pipeline is designed to preserve dataset completeness while keeping
|
| 473 |
-
Wikimedia traffic polite:
|
| 474 |
-
|
| 475 |
-
* Candidate order, selected sitelinks, and Parquet row ordering are
|
| 476 |
-
deterministic.
|
| 477 |
-
* Identical Wikidata QIDs and Wikipedia titles are fetched once per run and
|
| 478 |
-
reused for every matching polygon.
|
| 479 |
-
* HTTP clients use the on-disk cache by default. Failed requests are cached
|
| 480 |
-
briefly to avoid repeatedly hammering a failing endpoint.
|
| 481 |
-
* Concrete HTTP clients batch compatible Wikidata and same-language Wikipedia
|
| 482 |
-
requests. The pipeline falls back to the established per-item request path
|
| 483 |
-
if a batch response is incomplete or invalid.
|
| 484 |
-
* If a valid page returns an empty TextExtracts result, the client parses that
|
| 485 |
-
page's exact revision through the Action API and converts the rendered HTML
|
| 486 |
-
to plain text while preserving the original revision ID.
|
| 487 |
-
* Per-host pacing, retries with jitter, and a shared `429` cooldown remain in
|
| 488 |
-
force when batch jobs run concurrently.
|
| 489 |
-
* Long enrichment stages emit a concise two-minute heartbeat naming the active
|
| 490 |
-
Wikidata or Wikipedia phase, completed and total QIDs, completed and total
|
| 491 |
-
Wikipedia sites, and articles attempted. The snapshot confirms liveness; it is
|
| 492 |
-
not an ETA and does not change request pacing. Short enrichment stages finish
|
| 493 |
-
without a heartbeat.
|
| 494 |
-
* `--push` publishes every produced Parquet artifact and the final manifest in
|
| 495 |
-
one atomic Hugging Face commit. Transfers use concurrent workers; increase
|
| 496 |
-
`--upload-threads` only when local bandwidth and Hub quotas allow it.
|
| 497 |
-
|
| 498 |
-
For a repeatable production run, use `--skip-existing`; it consults the
|
| 499 |
-
manifest and leaves previously completed PBFs untouched. Use `--force` only
|
| 500 |
-
when you intentionally want to rebuild a completed PBF.
|
| 501 |
-
|
| 502 |
-
## Development quality checks
|
| 503 |
-
|
| 504 |
-
The project exposes the same uv-managed checks locally and in GitHub
|
| 505 |
-
Actions through `just`:
|
| 506 |
-
|
| 507 |
-
```bash
|
| 508 |
-
just check
|
| 509 |
-
```
|
| 510 |
-
|
| 511 |
-
Install the pre-commit hooks once per checkout:
|
| 512 |
-
|
| 513 |
-
```bash
|
| 514 |
-
uv run pre-commit install
|
| 515 |
-
```
|
| 516 |
-
|
| 517 |
-
The test suite uses in-memory clients and stub PBF readers for unit coverage.
|
| 518 |
-
It does not require a real PBF, external data root, or Wikimedia request.
|
| 519 |
-
|
| 520 |
-
### Read-only remote audit
|
| 521 |
-
|
| 522 |
-
The separate operator command uses Typer for its CLI, Rich for its report, and
|
| 523 |
-
tqdm for interactive per-region progress:
|
| 524 |
-
|
| 525 |
-
```bash
|
| 526 |
-
uv run osm-polygon-wikidata-only-audit-remote \
|
| 527 |
-
--data-root "$OSM_POLYGON_DATA_ROOT"
|
| 528 |
-
```
|
| 529 |
-
|
| 530 |
-
It compares finalized local artifacts with the Hugging Face inventory and
|
| 531 |
-
prints a reconciliation plan. It does not modify local files or the remote
|
| 532 |
-
dataset. The production `osm-polygon-wikidata-only` command remains a stable,
|
| 533 |
-
non-interactive argparse interface; `sync-dir` keeps its low-noise log
|
| 534 |
-
heartbeats instead of terminal progress bars.
|
| 535 |
-
|
| 536 |
-
---
|
| 537 |
-
|
| 538 |
-
## Output schema
|
| 539 |
-
|
| 540 |
-
Each PBF produces polygon and link tables plus canonical Wikipedia
|
| 541 |
-
documents and the derived text/fact tables. The schema
|
| 542 |
-
definitions live in `osm_polygon_wikidata_only.domain.schema` and
|
| 543 |
-
`osm_polygon_wikidata_only.augmentation.schema` so the dataset
|
| 544 |
-
card, the parquet writers, and the tests share a single source of
|
| 545 |
-
truth.
|
| 546 |
-
|
| 547 |
-
### `polygons/<stem>.parquet`
|
| 548 |
-
|
| 549 |
-
One row per polygon. Includes geometry metadata, OSM tags, primary
|
| 550 |
-
OSM tag, area bucket, and Wikipedia coverage counters.
|
| 551 |
-
|
| 552 |
-
### `wikipedia/documents/<stem>.parquet`
|
| 553 |
-
|
| 554 |
-
One row per unique Wikipedia article
|
| 555 |
-
(`(wikidata, language, page_id, revision_id)`). Includes lead text,
|
| 556 |
-
plain-text full text, thumbnails, license, attribution, and a
|
| 557 |
-
deterministic SHA-256 `content_hash`. It preserves every field from
|
| 558 |
-
the former `articles/` table and adds stable `document_id` and
|
| 559 |
-
`project` fields. The legacy remote `articles/` path is deleted in
|
| 560 |
-
the same atomic Hub commit as the canonical upload; the local
|
| 561 |
-
`processed/articles/` staging file is removed only after confirmed
|
| 562 |
-
publication and reference validation.
|
| 563 |
-
|
| 564 |
-
### `polygon_articles/<stem>.parquet`
|
| 565 |
-
|
| 566 |
-
Unified many-to-many links joining polygons to Wikipedia and Wikivoyage
|
| 567 |
-
documents. The `project` column identifies the source corpus and
|
| 568 |
-
`document_id` references the corresponding project document table.
|
| 569 |
-
|
| 570 |
-
### `manifests/processed_pbfs.json`
|
| 571 |
-
|
| 572 |
-
Aggregate stats per source PBF: polygon/article counts, language
|
| 573 |
-
coverage, area-bucket counts, top tag keys.
|
| 574 |
-
|
| 575 |
-
### Text and fact tables
|
| 576 |
-
|
| 577 |
-
Text sections, Wikivoyage documents, and Wikidata facts are published
|
| 578 |
-
when augmentation has run for a region. Wikipedia sections reference
|
| 579 |
-
the canonical document IDs; retiring the legacy article table never
|
| 580 |
-
removes or rewrites section content.
|
| 581 |
-
|
| 582 |
-
- `wikipedia/sections/<stem>.parquet` — section-level partitions of
|
| 583 |
-
Wikipedia document text.
|
| 584 |
-
- `wikivoyage/documents/<stem>.parquet` — full Wikivoyage documents
|
| 585 |
-
associated with places through Wikidata.
|
| 586 |
-
- `wikivoyage/sections/<stem>.parquet` — section-level partitions of
|
| 587 |
-
Wikivoyage document text.
|
| 588 |
-
- `wikidata/facts/<stem>.parquet` — structured Wikidata claims for
|
| 589 |
-
polygon entities.
|
| 590 |
-
|
| 591 |
-
Column lists for documents, sections, and facts live in
|
| 592 |
-
`osm_polygon_wikidata_only.augmentation.schema` (`DOCUMENT_COLUMNS`,
|
| 593 |
-
`SECTION_COLUMNS`, `FACT_COLUMNS`) and the documented column
|
| 594 |
-
descriptions live in
|
| 595 |
-
`osm_polygon_wikidata_only.augmentation.schema_descriptions`. The
|
| 596 |
-
generated Hugging Face dataset card (`README.md`) embeds every
|
| 597 |
-
augmentation column with its description; the dataset card renderer
|
| 598 |
-
is the source of truth for what's published.
|
| 599 |
-
|
| 600 |
-
## Generated dataset card
|
| 601 |
-
|
| 602 |
-
The published dataset card on the Hugging Face Hub is regenerated
|
| 603 |
-
automatically before every publication path. It reports factual
|
| 604 |
-
core, Wikipedia, Wikivoyage, section, and Wikidata-fact statistics
|
| 605 |
-
computed directly from the local finalized Parquet files under
|
| 606 |
-
`<processed>/`. No hardcoded counts live in the source repository
|
| 607 |
-
or the generated card; every figure is recomputed on each
|
| 608 |
-
publication.
|
| 609 |
-
|
| 610 |
-
The canonical renderer is `osm_polygon_wikidata_only.hf.publication.write_readme_snapshot`,
|
| 611 |
-
backed by `osm_polygon_wikidata_only.hf.dataset_stats.render_stats_section`
|
| 612 |
-
and `osm_polygon_wikidata_only.hf.dataset_card.render_dataset_card`.
|
| 613 |
-
The renderer pulls both the core `DatasetStats` snapshot and the
|
| 614 |
-
private augmentation snapshot from the local sidecars.
|
| 615 |
-
|
| 616 |
-
---
|
| 617 |
-
|
| 618 |
-
## Geographic coverage
|
| 619 |
|
| 620 |
### Polygons with Wikipedia or Wikivoyage text
|
| 621 |
|
| 622 |

|
| 623 |
|
| 624 |
-
Each point is a dataset polygon with at least one non-empty Wikipedia
|
| 625 |
-
document or a non-empty Wikivoyage document sharing its Wikidata entity.
|
| 626 |
-
A polygon is shown once even when several documents qualify.
|
| 627 |
|
| 628 |
### All dataset polygons
|
| 629 |
|
| 630 |

|
| 631 |
|
| 632 |
-
Each point represents one dataset polygon carrying an OSM `wikidata=*`
|
| 633 |
-
|
|
|
|
| 634 |
|
| 635 |
### Wikipedia + Wikivoyage text density
|
| 636 |
|
| 637 |

|
| 638 |
|
| 639 |
-
Each H3 cell contains the raw number of polygons with non-empty text
|
| 640 |
-
from Wikipedia or Wikivoyage. A polygon is counted once even when both
|
| 641 |
-
projects or several documents qualify. Colour uses a logarithmic
|
| 642 |
-
purple-to-yellow scale; this is an absolute density count, not a proportion
|
| 643 |
-
of all polygons.
|
| 644 |
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
## Wikimedia etiquette
|
| 648 |
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
-
|
| 656 |
-
`request_base_delay_s`,
|
| 657 |
-
* exponential backoff with jitter (`utils.retry.with_retries`),
|
| 658 |
-
* a disk-backed `JsonFileCache` (`io.cache.JsonFileCache`) that lets
|
| 659 |
-
repeated runs avoid hammering the same endpoint,
|
| 660 |
-
* localized language lists (`--languages`) so we never fetch
|
| 661 |
-
unwanted sitelinks.
|
| 662 |
|
| 663 |
-
|
| 664 |
-
[Bot Password setup](#wikimedia-bot-password-authentication). Bot Password
|
| 665 |
-
cookies are kept in memory and isolated per Wikimedia API host. Anonymous mode
|
| 666 |
-
remains available when neither credential environment variable is set.
|
| 667 |
|
| 668 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
|
| 670 |
-
|
| 671 |
|
| 672 |
-
###
|
| 673 |
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
|
| 678 |
-
The 1,300+ tracked tests are deterministic and require no live network;
|
| 679 |
-
HTTP clients come in three flavors (`Http…`, `InMemory…`,
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 690 |
|
| 691 |
-
```
|
| 692 |
-
|
|
|
|
|
|
|
|
|
|
| 693 |
```
|
| 694 |
-
|
| 695 |
-
Run `just --list` for every available recipe. All Python commands are executed
|
| 696 |
-
through uv; GitHub Actions uses the same coverage, lint, format-check,
|
| 697 |
-
type-check, and build recipes.
|
| 698 |
-
|
| 699 |
-
---
|
| 700 |
-
|
| 701 |
-
## Repository / data separation policy
|
| 702 |
-
|
| 703 |
-
The repository is **code-only**. Everything user-generated (datasets,
|
| 704 |
-
HF caches, Arrow/Parquet files, downloaded PBFs) is git-ignored and
|
| 705 |
-
must live on the configured external data root. This keeps the repo
|
| 706 |
-
tiny, makes data updates cheap, and prevents accidental commits of
|
| 707 |
-
multi-GB artifacts.
|
| 708 |
-
|
| 709 |
-
---
|
| 710 |
-
|
| 711 |
-
## Licensing and attribution
|
| 712 |
-
|
| 713 |
-
* **OpenStreetMap polygons**: (c) OpenStreetMap contributors, licensed
|
| 714 |
-
under [ODbL 1.0](https://opendatacommons.org/licenses/odbl/).
|
| 715 |
-
* **Wikidata** entity data: (c) Wikimedia contributors under
|
| 716 |
-
[CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/).
|
| 717 |
-
* **Wikipedia** article text: (c) respective Wikipedia authors,
|
| 718 |
-
licensed under
|
| 719 |
-
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
|
| 720 |
-
Attribution and license are stored inline in the
|
| 721 |
-
`wikipedia/documents/<stem>.parquet` `license` and `attribution`
|
| 722 |
-
columns.
|
| 723 |
-
|
| 724 |
-
Any derivative dataset must preserve OSM attribution as described on
|
| 725 |
-
<https://www.openstreetmap.org/copyright>.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: odbl
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- openstreetmap
|
| 7 |
+
- wikidata
|
| 8 |
+
- wikipedia
|
| 9 |
+
- wikivoyage
|
| 10 |
+
- polygons
|
| 11 |
+
- geospatial
|
| 12 |
+
- multilingual
|
| 13 |
+
configs:
|
| 14 |
+
- config_name: polygons
|
| 15 |
+
data_files:
|
| 16 |
+
- split: polygons
|
| 17 |
+
path: polygons/*.parquet
|
| 18 |
+
- config_name: polygon_articles
|
| 19 |
+
data_files:
|
| 20 |
+
- split: polygon_articles
|
| 21 |
+
path: polygon_articles/*.parquet
|
| 22 |
+
- config_name: wikipedia_documents
|
| 23 |
+
data_files:
|
| 24 |
+
- split: wikipedia_documents
|
| 25 |
+
path: wikipedia/documents/*.parquet
|
| 26 |
+
- config_name: wikipedia_sections
|
| 27 |
+
data_files:
|
| 28 |
+
- split: wikipedia_sections
|
| 29 |
+
path: wikipedia/sections/*.parquet
|
| 30 |
+
- config_name: wikivoyage_documents
|
| 31 |
+
data_files:
|
| 32 |
+
- split: wikivoyage_documents
|
| 33 |
+
path: wikivoyage/documents/*.parquet
|
| 34 |
+
- config_name: wikivoyage_sections
|
| 35 |
+
data_files:
|
| 36 |
+
- split: wikivoyage_sections
|
| 37 |
+
path: wikivoyage/sections/*.parquet
|
| 38 |
+
- config_name: wikidata_facts
|
| 39 |
+
data_files:
|
| 40 |
+
- split: wikidata_facts
|
| 41 |
+
path: wikidata/facts/*.parquet
|
| 42 |
+
dataset_info:
|
| 43 |
+
polygon_count: 1184110
|
| 44 |
+
unique_wikidata_count: 1119223
|
| 45 |
+
article_count: 2273750
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
# NoeFlandre/osm-polygon-wikidata-only
|
| 49 |
+
|
| 50 |
+

|
| 51 |
|
| 52 |
+
OSM polygons tagged with a `wikidata=*` reference, enriched with Wikipedia and Wikivoyage text across all available languages. The published tables are:
|
| 53 |
|
| 54 |
+
- `polygons/<stem>.parquet` — one row per polygon
|
| 55 |
+
- `wikipedia/documents/<stem>.parquet` — one row per unique Wikipedia article
|
| 56 |
+
- `polygon_articles/<stem>.parquet` — unified polygon-to-document many-to-many links for Wikipedia and Wikivoyage; `project` identifies the source and `document_id` references its document table
|
| 57 |
+
- `wikipedia/sections/<stem>.parquet` — section-level partitions of Wikipedia document text
|
| 58 |
+
- `wikivoyage/documents/<stem>.parquet` — full Wikivoyage documents associated with places through Wikidata
|
| 59 |
+
- `wikivoyage/sections/<stem>.parquet` — section-level partitions of Wikivoyage document text
|
| 60 |
+
- `wikidata/facts/<stem>.parquet` — structured Wikidata claims for polygon entities
|
| 61 |
|
| 62 |
+
Links are derived from the Wikidata identifiers shared by each OSM polygon and its Wikipedia or Wikivoyage documents.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
Generated on 2026-08-02.
|
| 65 |
|
| 66 |
+
Maintained by **Noé Flandre**.
|
| 67 |
+
|
| 68 |
+
Source code: [GitHub repository](https://github.com/NoeFlandre/osm-polygon-wikidata-only).
|
| 69 |
+
|
| 70 |
+
This Hugging Face dataset is **V1**, produced by the [V1.0.0 GitHub code](https://github.com/NoeFlandre/osm-polygon-wikidata-only/tree/v1.0.0).
|
|
|
|
| 71 |
|
| 72 |
## Trackio snapshot
|
| 73 |
|
| 74 |
+
[View the dataset presentation](https://noeflandre.github.io/osm-polygon-wikidata-only/presentations/dataset.html) for a visual overview of the published tables and geographic coverage.
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
The finished dataset is recorded in the single public Trackio run [`final-dataset-snapshot`](https://huggingface.co/spaces/NoeFlandre/osm-polygon-wikidata-only-trackio). It contains exactly three plots: a text-coverage funnel, the top ten Wikipedia languages plus `Other languages`, and dataset composition on a logarithmic scale. The run is a static snapshot with no pipeline timeline.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
| Snapshot metric | Value |
|
| 79 |
| --- | ---: |
|
|
|
|
| 89 |
| Polygon/link-table storage | 9.9 GB |
|
| 90 |
| Total Parquet storage | 19.2 GB |
|
| 91 |
|
| 92 |
+
The funnel's language thresholds use the canonical Wikipedia polygon fields. Wikivoyage is included in the combined document, word, and dataset-composition totals.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
### Polygons with Wikipedia or Wikivoyage text
|
| 97 |
|
| 98 |

|
| 99 |
|
| 100 |
+
Each point is a dataset polygon with at least one non-empty Wikipedia document or a non-empty Wikivoyage document sharing its Wikidata entity. A polygon is shown once even when several documents qualify.
|
|
|
|
|
|
|
| 101 |
|
| 102 |
### All dataset polygons
|
| 103 |
|
| 104 |

|
| 105 |
|
| 106 |
+
Each point represents one dataset polygon carrying an OSM `wikidata=*` tag, whether or not corresponding Wikipedia or Wikivoyage text is available.
|
| 107 |
+
|
| 108 |
+
## Geographic coverage
|
| 109 |
|
| 110 |
### Wikipedia + Wikivoyage text density
|
| 111 |
|
| 112 |

|
| 113 |
|
| 114 |
+
Each H3 cell contains the raw number of polygons with non-empty Wikipedia or Wikivoyage text. A polygon is counted once even when both projects or several documents qualify. Colour uses a logarithmic purple-to-yellow scale; this is an absolute density count, not a proportion of all polygons.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
## Dataset snapshot
|
|
|
|
|
|
|
| 117 |
|
| 118 |
+
| Metric | Value |
|
| 119 |
+
| --- | ---: |
|
| 120 |
+
| Polygons | 1,184,110 |
|
| 121 |
+
| Unique Wikidata entities | 1,119,223 |
|
| 122 |
+
| Wikipedia polygon-document links | 2,468,604 |
|
| 123 |
+
| Wikipedia + Wikivoyage languages | 351 |
|
| 124 |
+
| Geographic regions | 375 |
|
| 125 |
+
| Polygon and link tables size | 9.9 GB |
|
| 126 |
+
| Wikipedia documents | 2,273,750 |
|
| 127 |
+
| Wikipedia sections | 11,997,165 |
|
| 128 |
+
| Wikivoyage documents | 14,420 |
|
| 129 |
+
| Wikivoyage sections | 302,200 |
|
| 130 |
+
| Wikidata facts | 3,901,092 |
|
| 131 |
+
| Wikipedia + Wikivoyage document words | 801,528,334 |
|
| 132 |
+
| Total Parquet size | 19.2 GB |
|
| 133 |
+
|
| 134 |
+
Wikipedia + Wikivoyage document words sums the full Wikipedia and Wikivoyage documents and excludes section rows because sections duplicate document text.
|
| 135 |
+
|
| 136 |
+
## Language distribution
|
| 137 |
+
|
| 138 |
+
Top 20 languages across Wikipedia and Wikivoyage documents:
|
| 139 |
+
|
| 140 |
+
Document counts include canonical rows from both projects. Polygon counts deduplicate places per language and require non-empty text: Wikipedia uses the `polygon_articles` link table, while Wikivoyage joins through the shared Wikidata QID.
|
| 141 |
+
|
| 142 |
+
| Language | Documents | % of total | Polygons with non-empty text |
|
| 143 |
+
| --- | ---: | ---: | ---: |
|
| 144 |
+
| en | 223,301 | 10.1% | 238,950 |
|
| 145 |
+
| de | 146,312 | 6.6% | 158,550 |
|
| 146 |
+
| fr | 109,720 | 5.0% | 120,451 |
|
| 147 |
+
| ceb | 105,479 | 4.8% | 113,410 |
|
| 148 |
+
| sv | 74,518 | 3.4% | 79,076 |
|
| 149 |
+
| ru | 73,228 | 3.3% | 80,023 |
|
| 150 |
+
| es | 70,808 | 3.2% | 78,504 |
|
| 151 |
+
| it | 65,927 | 3.0% | 74,554 |
|
| 152 |
+
| pl | 65,685 | 3.0% | 70,164 |
|
| 153 |
+
| zh | 59,285 | 2.7% | 64,758 |
|
| 154 |
+
| ja | 54,072 | 2.5% | 58,226 |
|
| 155 |
+
| arz | 53,882 | 2.4% | 57,236 |
|
| 156 |
+
| nl | 52,953 | 2.4% | 58,130 |
|
| 157 |
+
| uk | 50,059 | 2.3% | 56,242 |
|
| 158 |
+
| fa | 38,840 | 1.8% | 42,279 |
|
| 159 |
+
| pt | 36,022 | 1.6% | 40,519 |
|
| 160 |
+
| ce | 32,849 | 1.5% | 34,597 |
|
| 161 |
+
| ca | 32,520 | 1.5% | 36,286 |
|
| 162 |
+
| cs | 28,497 | 1.3% | 32,286 |
|
| 163 |
+
| no | 28,424 | 1.3% | 31,793 |
|
| 164 |
+
|
| 165 |
+
**Concentration:**
|
| 166 |
+
- Top 1 language: 10.1% of all Wikipedia + Wikivoyage documents
|
| 167 |
+
- Top 5 languages: 29.9% of all Wikipedia + Wikivoyage documents
|
| 168 |
+
- Top 10 languages: 45.1% of all Wikipedia + Wikivoyage documents
|
| 169 |
+
- Top 20 languages: 63.6% of all Wikipedia + Wikivoyage documents
|
| 170 |
+
|
| 171 |
+
**Long-tail:**
|
| 172 |
+
- 351 language(s) total
|
| 173 |
+
- 5 language(s) appear in fewer than 5 Wikipedia + Wikivoyage documents
|
| 174 |
+
- 5 language(s) appear in fewer than 10 Wikipedia + Wikivoyage documents
|
| 175 |
+
- 4 language(s) appear in fewer than 5 polygons with non-empty text
|
| 176 |
+
|
| 177 |
+
## Storage accounting
|
| 178 |
+
|
| 179 |
+
Core tables size and total storage size are additive:
|
| 180 |
+
|
| 181 |
+
| Metric | Bytes | Human-readable |
|
| 182 |
+
| --- | ---: | --- |
|
| 183 |
+
| Polygon and link tables size | 2,243,135,062 | 2.1 GB |
|
| 184 |
+
| Wikipedia, Wikivoyage, and Wikidata tables size | 18,338,737,425 | 17.1 GB |
|
| 185 |
+
| Total Parquet size | 20,581,872,487 | 19.2 GB |
|
| 186 |
+
|
| 187 |
+
## Wikipedia text corpus
|
| 188 |
+
|
| 189 |
+
### Documents
|
| 190 |
+
|
| 191 |
+
| Metric | Value |
|
| 192 |
+
| --- | ---: |
|
| 193 |
+
| Document rows | 2,273,750 |
|
| 194 |
+
| Unique documents | 2,192,426 |
|
| 195 |
+
| Unique Wikidata entities | 625,432 |
|
| 196 |
+
| Languages | 351 |
|
| 197 |
+
| Non-empty text | 2,273,693 |
|
| 198 |
+
| Empty / null text | 57 |
|
| 199 |
+
| Characters | 5,324,562,350 |
|
| 200 |
+
| Words | 783,679,126 |
|
| 201 |
+
| Estimated tokens | 1,330,287,296 |
|
| 202 |
+
| Regions / files represented | 375 |
|
| 203 |
|
| 204 |
+
Estimated tokens use a transparent approximation: `characters // 4` per non-empty text row, with a minimum of one token per non-empty row.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
### Sections
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
+
| Metric | Value |
|
| 209 |
+
| --- | ---: |
|
| 210 |
+
| Section rows | 11,997,165 |
|
| 211 |
+
| Unique sections | 11,549,631 |
|
| 212 |
+
| Documents represented | 2,189,484 |
|
| 213 |
+
| Avg sections per represented document | 5.48 |
|
| 214 |
+
| Non-empty section rate | 100.0% |
|
| 215 |
+
| Unique Wikidata entities | 625,417 |
|
| 216 |
+
| Languages | 351 |
|
| 217 |
+
| Non-empty text | 11,997,165 |
|
| 218 |
+
| Empty / null text | 0 |
|
| 219 |
+
| Characters | 7,066,582,723 |
|
| 220 |
+
| Words | 1,108,894,757 |
|
| 221 |
+
| Estimated tokens | 1,762,125,212 |
|
| 222 |
+
| Regions / files represented | 375 |
|
| 223 |
|
| 224 |
+
Estimated tokens use a transparent approximation: `characters // 4` per non-empty text row, with a minimum of one token per non-empty row.
|
| 225 |
|
| 226 |
+
### Languages
|
| 227 |
|
| 228 |
+
| Language | Documents | % of total |
|
| 229 |
+
| --- | ---: | ---: |
|
| 230 |
+
| en | 224,462 | 9.9% |
|
| 231 |
+
| de | 149,091 | 6.6% |
|
| 232 |
+
| fr | 112,223 | 4.9% |
|
| 233 |
+
| ceb | 110,289 | 4.9% |
|
| 234 |
+
| sv | 76,085 | 3.3% |
|
| 235 |
+
| ru | 75,557 | 3.3% |
|
| 236 |
+
| es | 72,538 | 3.2% |
|
| 237 |
+
| it | 69,103 | 3.0% |
|
| 238 |
+
| pl | 66,276 | 2.9% |
|
| 239 |
+
| zh | 60,408 | 2.7% |
|
| 240 |
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
+
## Wikivoyage text corpus
|
| 243 |
|
| 244 |
+
### Documents
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
+
| Metric | Value |
|
| 247 |
+
| --- | ---: |
|
| 248 |
+
| Document rows | 14,420 |
|
| 249 |
+
| Unique documents | 14,137 |
|
| 250 |
+
| Unique Wikidata entities | 5,361 |
|
| 251 |
+
| Languages | 27 |
|
| 252 |
+
| Non-empty text | 14,417 |
|
| 253 |
+
| Empty / null text | 3 |
|
| 254 |
+
| Characters | 112,794,734 |
|
| 255 |
+
| Words | 17,849,208 |
|
| 256 |
+
| Estimated tokens | 28,193,232 |
|
| 257 |
+
| Regions / files represented | 375 |
|
| 258 |
+
|
| 259 |
+
Estimated tokens use a transparent approximation: `characters // 4` per non-empty text row, with a minimum of one token per non-empty row.
|
| 260 |
+
|
| 261 |
+
### Sections
|
| 262 |
+
|
| 263 |
+
| Metric | Value |
|
| 264 |
+
| --- | ---: |
|
| 265 |
+
| Section rows | 302,200 |
|
| 266 |
+
| Unique sections | 296,934 |
|
| 267 |
+
| Documents represented | 14,135 |
|
| 268 |
+
| Avg sections per represented document | 21.38 |
|
| 269 |
+
| Non-empty section rate | 100.0% |
|
| 270 |
+
| Unique Wikidata entities | 5,360 |
|
| 271 |
+
| Languages | 27 |
|
| 272 |
+
| Non-empty text | 302,200 |
|
| 273 |
+
| Empty / null text | 0 |
|
| 274 |
+
| Characters | 132,242,637 |
|
| 275 |
+
| Words | 21,741,293 |
|
| 276 |
+
| Estimated tokens | 32,946,346 |
|
| 277 |
+
| Regions / files represented | 375 |
|
| 278 |
+
|
| 279 |
+
Estimated tokens use a transparent approximation: `characters // 4` per non-empty text row, with a minimum of one token per non-empty row.
|
| 280 |
+
|
| 281 |
+
### Languages
|
| 282 |
+
|
| 283 |
+
| Language | Documents | % of total |
|
| 284 |
+
| --- | ---: | ---: |
|
| 285 |
+
| en | 3,434 | 23.8% |
|
| 286 |
+
| de | 1,898 | 13.2% |
|
| 287 |
+
| pl | 1,315 | 9.1% |
|
| 288 |
+
| it | 1,043 | 7.2% |
|
| 289 |
+
| fa | 970 | 6.7% |
|
| 290 |
+
| fr | 900 | 6.2% |
|
| 291 |
+
| zh | 537 | 3.7% |
|
| 292 |
+
| ru | 535 | 3.7% |
|
| 293 |
+
| es | 513 | 3.6% |
|
| 294 |
+
| nl | 509 | 3.5% |
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
## Wikidata facts
|
| 298 |
+
|
| 299 |
+
| Metric | Value |
|
| 300 |
+
| --- | ---: |
|
| 301 |
+
| Fact rows | 3,901,092 |
|
| 302 |
+
| Unique facts | 3,836,531 |
|
| 303 |
+
| Unique subjects | 955,700 |
|
| 304 |
+
| Distinct properties | 8 |
|
| 305 |
+
| Non-empty English property label | 3,901,092 |
|
| 306 |
+
| Non-empty English value label | 3,535,905 |
|
| 307 |
+
| With qualifiers | 232,610 |
|
| 308 |
+
| With references | 1,756,783 |
|
| 309 |
+
| Unreadable qualifier JSON | 3,668,482 |
|
| 310 |
+
| Unreadable references JSON | 2,144,309 |
|
| 311 |
+
| Regions / files represented | 375 |
|
| 312 |
+
|
| 313 |
+
**Value-type distribution:**
|
| 314 |
+
|
| 315 |
+
| Value type | Facts |
|
| 316 |
+
| --- | ---: |
|
| 317 |
+
| wikibase-item | 3,535,905 |
|
| 318 |
+
| time | 267,269 |
|
| 319 |
+
| quantity | 97,918 |
|
| 320 |
+
|
| 321 |
+
**Top properties:**
|
| 322 |
+
|
| 323 |
+
| Property ID | English label | Facts |
|
| 324 |
+
| --- | --- | ---: |
|
| 325 |
+
| P31 | instance of | 1,166,284 |
|
| 326 |
+
| P131 | located in the administrative territorial entity | 985,587 |
|
| 327 |
+
| P17 | country | 984,654 |
|
| 328 |
+
| P1435 | heritage designation | 336,569 |
|
| 329 |
+
| P571 | inception | 267,269 |
|
| 330 |
+
| P2044 | elevation above sea level | 97,918 |
|
| 331 |
+
| P361 | part of | 60,996 |
|
| 332 |
+
| P279 | subclass of | 1,815 |
|
| 333 |
+
|
| 334 |
+
English labels are requested where available; multilingual labels are preserved verbatim in the Parquet column `property_labels`.
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
## Geographic distribution by continent
|
| 338 |
+
|
| 339 |
+
This table is recomputed from the finalized Parquet tables before each dataset-card publication. Each polygon's WGS84 centroid is spatially matched to the bundled Natural Earth 1:110m Admin-0 country boundaries, then assigned the country's continent. Because this is a coarse global reference, offshore points and centroids outside its country polygons remain `Unassigned` rather than being guessed.
|
| 340 |
+
|
| 341 |
+
| Continent | Polygons | Wikipedia documents | Wikivoyage documents | Polygons with Wikipedia text | Polygons with Wikipedia or Wikivoyage text | Text coverage |
|
| 342 |
+
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
|
| 343 |
+
| Africa | 11,289 | 55,254 | 550 | 8,309 | 8,309 | 73.6% |
|
| 344 |
+
| Antarctica | 254 | 1,684 | 1 | 251 | 251 | 98.8% |
|
| 345 |
+
| Asia | 117,610 | 387,567 | 1,811 | 94,924 | 94,945 | 80.7% |
|
| 346 |
+
| Europe | 792,569 | 1,073,709 | 5,163 | 373,782 | 373,782 | 47.2% |
|
| 347 |
+
| North America | 162,012 | 392,739 | 3,429 | 120,166 | 120,167 | 74.2% |
|
| 348 |
+
| Oceania | 19,807 | 30,678 | 396 | 11,467 | 11,468 | 57.9% |
|
| 349 |
+
| South America | 18,906 | 63,181 | 786 | 13,503 | 13,503 | 71.4% |
|
| 350 |
+
| Unassigned | 61,663 | 193,785 | 2,007 | 43,824 | 43,826 | 71.1% |
|
| 351 |
+
|
| 352 |
+
**Metric definitions:**
|
| 353 |
+
|
| 354 |
+
- `Polygons`: dataset polygons whose centroid is assigned to the continent. Every polygon appears in exactly one continent row, including `Unassigned`.
|
| 355 |
+
- `Wikipedia documents`: distinct non-empty Wikipedia documents connected to those polygons through `polygon_articles`. A document is counted once within a continent, but may appear in more than one continent when linked polygons span more than one continent.
|
| 356 |
+
- `Wikivoyage documents`: distinct non-empty Wikivoyage documents whose Wikidata entity is shared by a polygon in the continent. The same cross-continent counting rule applies.
|
| 357 |
+
- `Polygons with Wikipedia text`: polygons linked to at least one non-empty Wikipedia document.
|
| 358 |
+
- `Polygons with Wikipedia or Wikivoyage text`: polygons satisfying the Wikipedia condition or sharing a Wikidata entity with at least one non-empty Wikivoyage document. Each polygon is counted once.
|
| 359 |
+
- `Text coverage`: `combined text-covered polygons / all dataset polygons` in the continent row.
|
| 360 |
+
|
| 361 |
+
## Schema
|
| 362 |
+
|
| 363 |
+
### `polygons`
|
| 364 |
+
|
| 365 |
+
| Column | Description |
|
| 366 |
+
| --- | --- |
|
| 367 |
+
| `polygon_id` | Deterministic ID: `<source_pbf_stem>:<osm_type>:<osm_id>`. |
|
| 368 |
+
| `region` | Geofabrik region slug parsed from the source PBF filename (e.g. `monaco`). |
|
| 369 |
+
| `source_pbf` | Source PBF filename (e.g. `monaco-latest.osm.pbf`). |
|
| 370 |
+
| `osm_type` | OSM element type: `way` or `relation`. |
|
| 371 |
+
| `osm_id` | OpenStreetMap numeric identifier of the element. |
|
| 372 |
+
| `wikidata` | Wikidata Q-id from the OSM `wikidata=*` tag. |
|
| 373 |
+
| `name` | Convenience: `tags.name` if present, empty string otherwise. |
|
| 374 |
+
| `tags` | Deterministic JSON object of all OSM tags except `wikidata`. |
|
| 375 |
+
| `tag_keys` | Deterministic JSON list of sorted OSM tag keys. |
|
| 376 |
+
| `tag_count` | Number of OSM tags (excluding `wikidata`). |
|
| 377 |
+
| `osm_primary_tag` | Best single tag for coarse analysis, e.g. `landuse=forest`. |
|
| 378 |
+
| `centroid` | Polygon centroid as a GeoJSON Point string (`[lon, lat]`). |
|
| 379 |
+
| `lat` | Centroid latitude in decimal degrees (WGS84). |
|
| 380 |
+
| `lon` | Centroid longitude in decimal degrees (WGS84). |
|
| 381 |
+
| `bbox` | Bounding box as JSON list `[min_lon, min_lat, max_lon, max_lat]`. |
|
| 382 |
+
| `geometry` | Full polygon geometry as deterministic GeoJSON string in WGS84 lon/lat coordinates. |
|
| 383 |
+
| `area_m2` | Polygon area in square meters (WGS84 equirectangular approximation). |
|
| 384 |
+
| `area_km2` | Polygon area in square kilometers. |
|
| 385 |
+
| `area_bucket` | Human-readable size bucket (e.g. `1-10km2`). |
|
| 386 |
+
| `has_name` | True if the polygon has a `name` tag. |
|
| 387 |
+
| `has_wikidata` | True if the polygon has a `wikidata` tag (always true by filter). |
|
| 388 |
+
| `has_wikipedia` | True if at least one linked Wikipedia article was fetched. |
|
| 389 |
+
| `wikipedia_language_count` | Number of Wikipedia languages for which articles were linked. |
|
| 390 |
+
| `wikipedia_languages` | Deterministic JSON list of language codes (e.g. `["en","fr"]`). |
|
| 391 |
+
| `wikipedia_article_count` | Number of unique article revisions linked to this polygon. |
|
| 392 |
+
| `has_english_wikipedia` | True if `en` is among the available languages. |
|
| 393 |
+
| `has_french_wikipedia` | True if `fr` is among the available languages. |
|
| 394 |
+
| `text_available` | True if at least one linked article has non-empty full text. |
|
| 395 |
+
| `best_language` | Deterministic preferred language code (e.g. `en`). |
|
| 396 |
+
| `extraction_version` | Package version that produced the row. |
|
| 397 |
+
| `extracted_at` | ISO-8601 UTC timestamp at the moment the row was extracted. |
|
| 398 |
+
|
| 399 |
+
### `wikipedia/documents`
|
| 400 |
+
|
| 401 |
+
| Column | Description |
|
| 402 |
+
| --- | --- |
|
| 403 |
+
| `document_id` | Deterministic document identifier (`<wikidata>:<project>:<language>:<page_id>:<revision_id>`). |
|
| 404 |
+
| `article_id` | Deterministic ID: `<wikidata>:<language>:<page_id>:<revision_id>`. |
|
| 405 |
+
| `wikidata` | Wikidata Q-id this article is linked to. |
|
| 406 |
+
| `project` | Wiki project name: always `wikipedia` for this table. |
|
| 407 |
+
| `language` | Wikipedia language code, e.g. `en`. |
|
| 408 |
+
| `site` | Wikidata sitelink site, e.g. `enwiki`. |
|
| 409 |
+
| `title` | Article title as returned by the Wikipedia API. |
|
| 410 |
+
| `url` | Canonical Wikipedia article URL. |
|
| 411 |
+
| `page_id` | MediaWiki page ID. |
|
| 412 |
+
| `revision_id` | Exact revision ID used for text extraction. |
|
| 413 |
+
| `revision_timestamp` | ISO-8601 timestamp of the revision. |
|
| 414 |
+
| `retrieved_at` | ISO-8601 UTC timestamp when this pipeline fetched the article. |
|
| 415 |
+
| `wikidata_label` | Best Wikidata label for the article's language, fallback English. |
|
| 416 |
+
| `wikidata_description` | Best Wikidata description for the article's language. |
|
| 417 |
+
| `wikidata_aliases` | Deterministic JSON list of Wikidata aliases. |
|
| 418 |
+
| `lead_text` | Lead section of the article, plain text. |
|
| 419 |
+
| `extract` | Short summary/extract if the API provided one. |
|
| 420 |
+
| `full_text` | Full cleaned article text, plain text. |
|
| 421 |
+
| `full_text_format` | Encoding of `full_text`; always `plain_text`. |
|
| 422 |
+
| `article_length_chars` | Length of `full_text` in characters. |
|
| 423 |
+
| `article_length_words` | Approximate whitespace-token count of `full_text`. |
|
| 424 |
+
| `article_length_tokens_estimate` | Rough token count: `chars / 4`. |
|
| 425 |
+
| `thumbnail_url` | Thumbnail URL only (no image bytes stored). |
|
| 426 |
+
| `thumbnail_width` | Thumbnail width in pixels, if known. |
|
| 427 |
+
| `thumbnail_height` | Thumbnail height in pixels, if known. |
|
| 428 |
+
| `categories` | Deterministic JSON list of category titles, or `[]`. |
|
| 429 |
+
| `license` | License string, e.g. `CC BY-SA`. |
|
| 430 |
+
| `attribution` | Attribution string for the article. |
|
| 431 |
+
| `source_api` | Which API was queried: `mediawiki_action_api` / `wikipedia_rest_api`. |
|
| 432 |
+
| `fetch_status` | One of: `ok`, `article_not_found`, `http_error`, `rate_limited`, `parse_error`, `empty_text`. |
|
| 433 |
+
| `fetch_error` | Short diagnostic on failure, empty string on success. |
|
| 434 |
+
| `content_hash` | Stable SHA-256 of `full_text` for change tracking. |
|
| 435 |
+
|
| 436 |
+
### `polygon_articles`
|
| 437 |
+
|
| 438 |
+
| Column | Description |
|
| 439 |
+
| --- | --- |
|
| 440 |
+
| `polygon_id` | FK to polygons polygon_id. |
|
| 441 |
+
| `document_id` | FK to the project documents table. Format: <wikidata>:<project>:<language>:<page_id>:<revision_id>. |
|
| 442 |
+
| `project` | Source project: wikipedia or wikivoyage. |
|
| 443 |
+
| `wikidata` | Wikidata QID (denormalized for fast filtering). |
|
| 444 |
+
| `language` | Document language code. |
|
| 445 |
+
| `source_pbf` | Source PBF filename (denormalized). |
|
| 446 |
+
| `region` | Geofabrik region slug (denormalized). |
|
| 447 |
+
| `osm_type` | OSM element type: way or relation. |
|
| 448 |
+
| `osm_id` | OSM numeric identifier. |
|
| 449 |
+
| `page_id` | MediaWiki page ID. |
|
| 450 |
+
| `revision_id` | MediaWiki revision ID. |
|
| 451 |
+
|
| 452 |
+
### `wikivoyage/documents`
|
| 453 |
+
|
| 454 |
+
| Column | Description |
|
| 455 |
+
| --- | --- |
|
| 456 |
+
| `document_id` | Deterministic document identifier (`<wikidata>:<project>:<language>:<page_id>:<revision_id>`). |
|
| 457 |
+
| `article_id` | Stable article identifier referenced by `polygon_articles/<stem>.parquet`. |
|
| 458 |
+
| `wikidata` | Wikidata QID this document is linked to. |
|
| 459 |
+
| `project` | Wiki project name: `wikipedia` or `wikivoyage`. |
|
| 460 |
+
| `language` | Wikipedia or Wikivoyage language code (e.g. `en`). |
|
| 461 |
+
| `site` | Wikidata sitelink host, e.g. `enwiki` or `enwikivoyage`. |
|
| 462 |
+
| `title` | Page title as returned by the MediaWiki API. |
|
| 463 |
+
| `url` | Canonical URL of the page. |
|
| 464 |
+
| `page_id` | MediaWiki page ID (integer). |
|
| 465 |
+
| `revision_id` | MediaWiki revision ID used to fetch the page text (integer). |
|
| 466 |
+
| `revision_timestamp` | ISO-8601 timestamp of the revision. |
|
| 467 |
+
| `retrieved_at` | ISO-8601 UTC timestamp when the pipeline fetched the page. |
|
| 468 |
+
| `full_text` | Cleaned plain-text document body (Wikipedia articles or Wikivoyage pages). |
|
| 469 |
+
| `full_text_format` | Encoding of `full_text`; always `plain_text`. |
|
| 470 |
+
| `article_length_chars` | Length of `full_text` in characters. |
|
| 471 |
+
| `article_length_words` | Approximate whitespace-token count of `full_text`. |
|
| 472 |
+
| `article_length_tokens_estimate` | Rough token estimate: `chars / 4`. |
|
| 473 |
+
| `license` | License string (`CC BY-SA` for Wikipedia/Wikivoyage text). |
|
| 474 |
+
| `attribution` | Attribution string for the page. |
|
| 475 |
+
| `source_api` | Which API was queried: `mediawiki_action_api` or `wikivoyage_rest_api`. |
|
| 476 |
+
| `fetch_status` | One of: `ok`, `page_not_found`, `http_error`, `rate_limited`, `parse_error`, `empty_text`. |
|
| 477 |
+
| `fetch_error` | Short diagnostic on failure, empty string on success. |
|
| 478 |
+
| `content_hash` | Stable SHA-256 of `full_text` for change tracking. |
|
| 479 |
+
|
| 480 |
+
### `wikipedia/sections` and `wikivoyage/sections`
|
| 481 |
+
|
| 482 |
+
| Column | Description |
|
| 483 |
+
| --- | --- |
|
| 484 |
+
| `section_id` | Deterministic SHA-256 over `(document_id, section_index, anchor)`. |
|
| 485 |
+
| `document_id` | FK back to `documents` (Wikipedia or Wikivoyage). |
|
| 486 |
+
| `article_id` | FK back to the corresponding `articles` row. |
|
| 487 |
+
| `wikidata` | Wikidata QID (denormalized for fast filtering). |
|
| 488 |
+
| `project` | Wiki project name: `wikipedia` or `wikivoyage`. |
|
| 489 |
+
| `language` | Wikipedia or Wikivoyage language code. |
|
| 490 |
+
| `site` | Wikidata sitelink host. |
|
| 491 |
+
| `page_id` | MediaWiki page ID (integer). |
|
| 492 |
+
| `revision_id` | MediaWiki revision ID (integer). |
|
| 493 |
+
| `section_index` | Sequential position of the section inside the document (integer). |
|
| 494 |
+
| `heading` | Section heading, or empty string when the section is the lead. |
|
| 495 |
+
| `anchor` | Section anchor after MediaWiki parsing. |
|
| 496 |
+
| `level` | Heading level (1..6), or 0 for the lead section (integer). |
|
| 497 |
+
| `parent_section_id` | Section ID of the enclosing section, or empty string. |
|
| 498 |
+
| `section_path` | JSON array of ancestor section IDs, in order. |
|
| 499 |
+
| `text` | Plain-text section body. |
|
| 500 |
+
| `text_length_chars` | Length of `text` in characters (integer). |
|
| 501 |
+
| `text_length_words` | Approximate whitespace-token count of `text` (integer). |
|
| 502 |
+
| `text_length_tokens_estimate` | Rough token estimate: `chars / 4` (integer). |
|
| 503 |
+
| `content_hash` | Stable SHA-256 of `section.text`. |
|
| 504 |
+
| `license` | License string for this section. |
|
| 505 |
+
| `attribution` | Attribution string for this section. |
|
| 506 |
+
|
| 507 |
+
### `wikidata/facts`
|
| 508 |
+
|
| 509 |
+
| Column | Description |
|
| 510 |
+
| --- | --- |
|
| 511 |
+
| `fact_id` | Deterministic SHA-256 over `(subject, property, value, ordinal)`. |
|
| 512 |
+
| `wikidata` | Wikidata QID the fact belongs to (the subject). |
|
| 513 |
+
| `property_id` | Property P-id (e.g. `P17`). |
|
| 514 |
+
| `property_label_en` | English label for the property, when available. |
|
| 515 |
+
| `property_labels` | Deterministic JSON object of property labels per language. |
|
| 516 |
+
| `value_type` | Wikidata value datatype: `wikibase-entityid`, `string`, `quantity`, `time`, ... |
|
| 517 |
+
| `value_entity_id` | Entity-valued object QID, when the value is a Wikidata entity. |
|
| 518 |
+
| `value_label_en` | English label for the value entity, when available. |
|
| 519 |
+
| `value_labels` | Deterministic JSON object of value labels per language. |
|
| 520 |
+
| `value_text` | Rendered text representation of the value. |
|
| 521 |
+
| `numeric_value` | Numeric amount for `quantity`-typed values, otherwise null. |
|
| 522 |
+
| `unit_entity_id` | Wikidata QID of the unit (e.g. `Q11573` for metre). |
|
| 523 |
+
| `rank` | Wikidata rank: `preferred`, `normal`, or `deprecated`. |
|
| 524 |
+
| `qualifiers` | Deterministic JSON object of qualifier snaks, or `{}` when absent. |
|
| 525 |
+
| `references` | Deterministic JSON array of reference groups, or `[]` when absent. |
|
| 526 |
+
| `retrieved_at` | ISO-8601 UTC timestamp when the pipeline fetched the entity. |
|
| 527 |
+
| `source_api` | Which API was queried (always `wikidata_action_api`). |
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
## Data sources & licenses
|
| 531 |
+
|
| 532 |
+
- **OpenStreetMap** polygons: (c) OpenStreetMap contributors, licensed under [ODbL 1.0](https://opendatacommons.org/licenses/odbl/).
|
| 533 |
+
- **Wikidata** entity data: [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/).
|
| 534 |
+
- **Wikipedia** article text: licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) by the respective Wikipedia editors; attributed inline per article.
|
| 535 |
+
- **Wikivoyage** text: licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) by the respective Wikivoyage editors; attributed inline per document.
|
| 536 |
+
- **Natural Earth** Admin-0 geography: public-domain 1:110m reference data used only to assign centroid-based continent statistics and draw context maps.
|
| 537 |
+
|
| 538 |
+
## How to load
|
| 539 |
|
| 540 |
+
```python
|
| 541 |
+
from datasets import load_dataset
|
| 542 |
+
ds = load_dataset("parquet", data_files={
|
| 543 |
+
"polygons": "hf://datasets/NoeFlandre/osm-polygon-wikidata-only/polygons/*.parquet",
|
| 544 |
+
})
|
| 545 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|