spa-l2-cairo-shop-knn
Analyst notes
Description
This task chains three spatial primitives (k-nearest neighbours, within-distance flagging, and a small distance matrix) on a medium-scale point layer, with an attribute-cleaning step folded on top. The hidden gotcha is that the chain names in the source are deliberately inconsistent across Arabic, Latin, and casing variants, and the prompt asks for consistency without naming the transliteration axes. The bundled GPKG is already in a metric CRS (EPSG:22992, Egypt Red Belt), so a correct solution computes distances directly without reprojection.
Approach
- Open the GPKG and inspect both layers to find the CRS, the column names, and the spread of raw shop names.
- For each of the 100 anchors, compute distances to all shops in the layer's metric CRS and keep the five nearest, sorted ascending.
- Derive the within-1 km boolean from the metric distance rather than guessing it from another column.
- For each anchor, find its three closest sibling anchors and build the 5 by 3 distance matrix from the chosen knn shops to those siblings, keeping rows aligned with the knn order.
- Cluster the raw shop names into chains across the transliteration variants, pick one canonical spelling per chain, and apply the same canonical name to every shop in that chain.
- Tidy the anchor names (strip whitespace and casing junk) and serialise the result as a top-level JSON array following the schema in the prompt.
Pitfalls
- Computing distances in degrees instead of metres makes every distance roughly five orders of magnitude too small, so the within-1 km flag flips to true for everything and the knn distance check rejects the output.
- Reporting distances in kilometres or feet instead of metres trips the same coord-derived distance check because the grader recomputes the true metric distance from the bundled coordinates.
- Picking the five farthest shops or reversing the sort order looks structurally valid but fails the knn distance vector check against the reference.
- Skipping the chain canonicalisation step and echoing the raw names verbatim leaves Arabic and Latin transliterations split across distinct values, which fails the chain-collapse subcheck even when the geometry is perfect.
- Over-collapsing across chains (mapping every supermarket to a single generic name like "supermarket") satisfies the per-chain distinct count but defeats the analytical purpose; the grader does not catch this directly, so the agent has to apply common sense.
- Building the distance matrix with the rows and columns transposed, or filling it with zeros because the sibling-anchor lookup was skipped, fails the matrix consistency subcheck.
- Writing the result as CSV or GeoJSON instead of a top-level JSON array misses Gate 1 and scores zero regardless of the rest of the pipeline.
Map
Recent runs task v2
| adapter | started | score | steps | duration | cost | status |
|---|---|---|---|---|---|---|
| openrouter-gemma4-26b-basic | 2026-06-18T07:32:32Z | pending | — | — | — | pending |
| openrouter-deepseek-v4-flash-basic | 2026-06-18T03:08:04Z | done | 25 | 4:41 | 2.60¢ | done |
| openrouter-deepseek-v4-flash-detailed | 2026-06-17T22:01:33Z | done | 21 | 2:43 | 0.87¢ | done |
| openrouter-gemma4-26b-detailed | 2026-06-17T19:47:47Z | done | 14 | 2:29 | 2.82¢ | done |
| openrouter-deepseek-v4-flash-basic | 2026-06-16T21:43:55Z | 1.00 | 19 | 3:29 | 1.38¢ | done |