Fourteen Fenton Bluffs subdivision wells (1988-1992) from the DCP scanned archive plus three 2023 reports from the DCP online dataset, transcribed in evidence/wells/neighbor-wells.json with the page images. tools/dcp_wells.py downloads, splits, OCRs and greps the town-year TIFFs.
100 lines
5.4 KiB
Markdown
100 lines
5.4 KiB
Markdown
# 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/`.
|
||
|
||
## dcp_wells.py: neighbour well completion reports
|
||
|
||
Connecticut well completion reports (depth, casing, yield, static level, formation log, lot
|
||
sketch) come from two places:
|
||
|
||
- **1970–2020**: DCP scanned the paper reports as one multi-page TIFF per town per year, in a
|
||
public S3 bucket (`http://s3-dcp-01.s3.amazonaws.com/data/<Town>/`, linked from the DCP
|
||
Well Drilling page as "Statewide Well Drilling Reports, 1970 - Present"). Each report is a
|
||
permit page with a sketch of the lot followed by the completion report. They are filed by
|
||
subdivision lot number and road, rarely by house number, so grep for road names and read the
|
||
sketches. Find the year from the assessor card ("Year Built"); the well is usually drilled in
|
||
the same year or the one before.
|
||
- **2021 onward**: the "Wells in Connecticut" Socrata dataset on data.ct.gov (`wphv-ux6v`),
|
||
with coordinates, depth, yield and links to the scanned permit and report PDFs on
|
||
elicense.ct.gov:
|
||
`https://data.ct.gov/resource/wphv-ux6v.json?$where=upper(well_city) like '%WILLINGTON%'&$limit=5000`
|
||
|
||
The script downloads the town-year TIFFs, splits the pages, OCRs them with tesseract and greps
|
||
the text; matching pages and the page after each (the report that follows a permit) are written
|
||
as 1300 px JPEGs for reading:
|
||
|
||
```
|
||
tools/dcp_wells.py --town Willington --years 1986-1992 --grep "fenton|potter|balaz" --out /tmp/wells
|
||
```
|
||
|
||
OCR of 569 pages takes about ten minutes on 14 cores. Handwritten numbers OCR badly; read the
|
||
JPEGs, do not trust the text for values. The Willington 049-002-00 results are in
|
||
`properties/willington-ct-049-002-00/evidence/wells/`.
|