property-research/tools/README.md
acamilo 580ec17fff Willington 049-002-00: add georeferenced 1951, 1965, 1970 and 1986 aerial layers and dam evidence
Register four historical frames from the UConn MAGIC and CT State Library
archives, aligned to the 1990 orthophoto with tools/georef_frame.py, and
file the DEEP dam query, topo and aerial comparisons under evidence/dam.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 20:35:43 -04:00

3.8 KiB

tools

Helper scripts kept beside the property research. They run with uv run and declare their own dependencies in the shebang, so nothing needs installing beyond uv.

georef_frame.py: historical aerial frames as viewer layers

Turns an unrectified historical aerial photo (a UConn MAGIC or Connecticut State Library scan) into a georeferenced display layer on a property's viewer grid, written as terrain/aerial-<year>.jpg with a .jgw world file and .prj, the same format the existing 1934/1990/2023 layers use.

Where the frames come from

The UConn Library MAGIC Air Photo Archive viewer (https://experience.arcgis.com/experience/f8a0f2a626094c56a4b09a2b82ba3cf1) is backed by one ArcGIS feature service per flight year holding photo centre points with download links. Query them by point and radius, f=json, outFields=*:

Year Layer URL (services1.arcgis.com/6ItOFXGFmdtfeOZb/arcgis/rest/services/...) Download field
1934 1934_CTSL_CTDA/FeatureServer/0 Download_TIF
1951-52 Airphoto_1951_CT/FeatureServer/2 TIF, PDF
1957 (Middlesex only) Airphoto_1957_CT/FeatureServer/1
1965 1965_CTSL_CTDA/FeatureServer/0 Download_TIF (CT Digital Archive, large files)
1970 Airphoto_1970_CT/FeatureServer/2 DOWNLOAD_T
1986 Airphoto_1986_CTJune2024/FeatureServer/0 Download_T
1990 Airphoto_1990_CT1/FeatureServer/5 Download_T

Caveats learned the hard way:

  • The SCALE attribute is unreliable (a frame tagged 1:6000 covered 5 km). Let the script sweep scale.
  • Frames are not north-up to better than a few degrees; the script sweeps rotation too.
  • 1965 frames from the CT Digital Archive are 230 MB TIFFs.
  • Water is dark in most years but white in the 1965 flight (ice or glare).

Reference imagery

Export a georeferenced reference around the parcel from CT ECO in EPSG:6434 (CT state plane, US ft):

https://cteco.uconn.edu/ctraster/rest/services/images/Ortho_1990/ImageServer/exportImage
  ?bbox=<x0>,<y0>,<x1>,<y1>&bboxSR=6434&imageSR=6434&size=3000,3000&format=tiff&f=image

Save it with a ref.json beside it: {"bbox":[x0,y0,x1,y1],"size":3000}. A 5.5 km box at 6 ft/px worked. Mosaic_1934_MAGIC is also available as a reference for the 1951 flight. Ortho_2023 refused a 3000 px three-band export (HTTP 500); use a smaller size if it is needed.

Running it

uv run --no-project --with opencv-python-headless --with numpy --with pillow python3 -I \
  tools/georef_frame.py --frame frame.tif --ref ref/Ortho_1990.tif --refmeta ref/ref.json \
  --template properties/<id>/terrain/aerial-1990.jgw --prj properties/<id>/terrain/aerial-1990.prj \
  --out properties/<id>/terrain/aerial-1970 --check check-1970.png --scales 0.8:2.5

Method: blurred gradient images, brute-force sweep of scale and rotation with normalized cross-correlation of the frame's central part against the reference, then ECC affine refinement. No relief correction, so expect several metres of error on steep ground and more at frame edges.

Always look at the --check checkerboard (alternating 100 px tiles of the new layer and the template): roads, streams and pond shores must run straight across tile edges. The numeric "verify" figures in the report are weak for imagery decades apart; the picture is the test. SIFT feature matching was tried first and failed on these films (under 12 inliers), which is why the script does not use it.

Registering the layer

Add the asset to terrain/collection.json (assets), the entry to terrain/terrain-data.json (assets.imagery), and the id to report-manifest.json (layers and inputs). The Willington 049-002-00 entries for 1951, 1965, 1970 and 1986 are the model; each carries georeferencing and caveat fields and points at its .georef.json report and check image under terrain/evidence/.