MapFix-Spatial — Explained

One line: the smallest, most demo-able project, an interactive web app that takes warped/distorted geographic coordinates, estimates the distortion field, and iteratively "un-warps" them back onto a clean map projection, with an optional LLM/image layer that narrates and renders the fix.

Honest status up front. This is a single-file interactive MVP (server.py, 457 LOC) + a browser front-end, not a trained model. The distortion-and-correction math is real and deterministic (it runs); the distortion itself is a synthetic, parametric model (a "Mercator repair" profile with curve/shear knobs), so it demonstrates the method on controllable distortion rather than on real misregistered maps. The OpenAI calls (/api/correct text analysis, /api/render-map image) are an optional flavor layer; without a key it falls back to a deterministic summary. In short: "a working interactive demo of distortion estimation + fixed-point correction on a parametric distortion model; the engine is real, the distortion is synthetic, and the LLM layer is optional polish."


1. What it is and the gap it fills

Geospatial coordinates arrive distorted all the time: bad georeferencing, projection mismatches, sensor warp. MapFix is the interactive teaching/demo version of "detect and undo that distortion." You give it points, it models the distortion as a smooth field, inverts it by fixed-point iteration, and shows you the residual error and how much area it recovered, live in the browser. It's the lightweight, clickable face of the same distortion-aware theme that runs through sat-splat (camera Jacobians) and darkvessel (sensor co-registration).


2. Architecture and data flow

 input points ──► normalize to [0,1] (bounds_for / normalize_point)
        │
        ├─► apply_distortion: synthetic warp via distortion_vector(curve, shear, noise, seed)
        ▼
 correct_point: fixed-point iteration to invert the distortion
        │
        ├─► gradient_at: finite-difference the distortion field (Jacobian probe)
        ▼
 metrics_for / coordinate_rows: residual px, % area recovered, per-point table
        │
        └─► /api/correct (OpenAI text analysis)  +  /api/render-map (image)  [optional]

3. Walkthrough (it's one file: server.py)


4. The core idea, from scratch

Inverting a distortion by fixed-point iteration. If the warp is raw = clean + D(clean) for a small smooth field D, you can't solve for clean directly, but if D is a contraction you can iterate clean ← raw − D(clean_estimate) until it converges. That's exactly correct_point. The gradient_at finite-difference gives the local Jacobian of D, which both diagnoses convergence and connects conceptually to the analytic Jacobians in sat-splat (there, derived in closed form; here, probed numerically).

The honest limitation: the distortion is a known parametric model the app both applies and inverts, so it's a controlled demonstration, not a learned correction of real-world warp. That's the right scope for an interactive MVP.


5. What's real vs scaffold

Piece Status
Distortion model + fixed-point correction + metrics Real, deterministic, runs
Interactive browser demo (GitHub Pages) Real, live
OpenAI text + image layer Real but optional (falls back without a key)
Correction of real misregistered maps Not yet (distortion is synthetic/parametric)

6. What I'd do next

  1. Feed real misregistered control points (e.g. GCPs with known offsets) instead of the synthetic warp, so the correction is evaluated on real distortion.
  2. Fit the distortion field (thin-plate spline or a small learned field) from observed point pairs rather than assuming the parametric model.
  3. Report a real accuracy number (RMSE before/after on held-out control points).
  4. Connect it to the portfolio: use the same fix to align two real images (the darkvessel SAR/optical co-registration use case), making the distortion-aware theme one continuous story.

Plain-language explainer for MapFix-Spatial, grounded in the real code and honest about scope. Full paper page · Portfolio