OSM change detection: incorporate OSM changes and closures in conflation#29
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The current codebase only conflates between Overture Maps and currently open OpenStreetMap points of interest; it does not consider OSM POIs that have recently closed. However, the latter is useful information that can improve the quality of our combined dataset.
This PR uses the OSM history file to develop a list of POI closures and substantial changes. These changes are then compared to the Overture Maps POIs. Overture POIs with that match a previously-changed OSM POI on location, type, and name have their confidence downweighted.
Changes
Adds an OSM-history-derived change-detection layer to the conflation pipeline. For each unmatched-Overture POI in the conflated dataset, we shadow-match against a "ghost" — a previous state of an OSM element we believe no longer reflects ground truth (deletion / lifecycle-prefix / primary-tag-removal / substantial rename). Matches get their
conf_meanmultiplied by the per-shared_labelδ from the fitted turnover model, with audit columns appended so the demoted rows can be inspected.make conflateis now the canonical entry point for national runs and includes the CD penalty automatically. The pre-CD conflated parquet is preserved asconflated_baseline.parquetfor spot-checks and ablation.What's in the diff
~2,730 line-changes across 14 files, plus a Makefile target and docs.
src/openpois/conflation/ghost_osm.py(new)_scan_all_changesoverosm_changes.parquet; emits at most one ghost per(element, version)of typehard_delete,lifecycle_prefix_added,primary_tag_deleted, orsubstantial_rename. Nodes only.src/openpois/conflation/change_detection.py(new)find_shadow_matches(BallTree + composite scoring),apply_current_survivor_filter(R1 — drops penalties when a live OSM POI with the same name lives within 50 m),apply_shadow_match(orchestrator + audit columns + δ penalty).src/openpois/io/osm_history_pbf.pyosmium tags-filter→ ID list →osmium getid --with-history) so the parsed parquet retains deletion versions. Recovers ~600 khard_deleteevents nationwide that a singletags-filterpass silently drops.scripts/conflation/build_ghosts.py,apply_change_detection.py,diff_change_detection.py(all new)scripts/conflation/conflate.py--output-suffixso the no-CD baseline and the CD-applied canonical output can coexist.Makefileconflate/build_ghosts/conflate_baseline/apply_cdtargets. Each tees a per-run log under~/data/openpois/logs/.vetting_viz/(new)python -m http.server. Includes a Seattle evaluation script.config.yamldirectories.ghost_osm,versions.ghost_osm, andconflation.change_detectionblock (min_shadow_match_score,default_delta,min_prior_name_match_score,suppress_if_current_survivor).docs/change-detection.md(new).claude/CLAUDE.md..claude/skills/conflate-snapshots/SKILL.mdmake conflateand list the new sub-targets and outputs..claude/TODO.mdST_Distance_Spherecorrectness bug.How a national run looks now
Sub-targets (
make build_ghosts,make conflate_baseline,make apply_cd) are exposed for partial re-runs when iterating on a single stage.Validation
Hand-vetted 290-row Seattle ground-truth set:
The remaining ~20 % FPR is intrinsic to the design — OSM history captures closures but is silent on openings, so a real closure plus a different current business with a similar name + location + type reads as evidence Overture is stale.
Performance
build_ghostsconflate_baselineapply_cdThe R1 current-OSM-survivor filter uses a sklearn
BallTreehaversine query over rated-snapshot centroids extracted via DuckDB SQL (no shapely-Python materialization). This replaced a DuckDB cross-product spatial join that was ~25 s wall and ~8.5 GB peak on Seattle alone; the new path is 5-6 s wall and 1 GB on Seattle, and scales linearly to nationwide.Notable findings flagged during development
ST_Distance_Spherereturns incorrect distances — the bundled spherical-distance formula is off by ~25 % at continental scale (NYC → LA returns 4,911 km vs the correct ~3,940 km) and similarly at small scales (a 65 m Seattle pair reads as 43 m). The R1 filter avoids this by going throughBallTreehaversine. Any new code touching this area should avoidST_Distance_Sphereuntil the pin is bumped. Tracked in.claude/TODO.md.min_prior_name_match_scoreships at 0 (loose matcher). Setting it to 70 produces high-precision but narrow-recall results that miss the bulk of real closures where Overture has updated to a different current business name at a churned address (Sleep Train → Roosevelt Square type cases). The knob remains in config + CLI for future data-quality-only modes. The docstring onfind_shadow_matchesrecords the reasoning.