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>
This commit is contained in:
acamilo 2026-10-07 20:35:43 -04:00
parent 3fcb127344
commit 580ec17fff
30 changed files with 1278 additions and 6 deletions

View file

@ -0,0 +1 @@
{"objectIdFieldName":"OBJECTID","uniqueIdField":{"name":"OBJECTID","isSystemMaintained":true},"globalIdFieldName":"","geometryType":"esriGeometryPoint","spatialReference":{"wkid":4326,"latestWkid":4326},"fields":[{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"OBJECTID_1","type":"esriFieldTypeInteger","alias":"OBJECTID","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"DAM_NO","type":"esriFieldTypeDouble","alias":"DAM_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"DAM_NAME","type":"esriFieldTypeString","alias":"DAM_NAME","sqlType":"sqlTypeOther","length":100,"domain":null,"defaultValue":null},{"name":"ALT_NAME","type":"esriFieldTypeString","alias":"ALT_NAME","sqlType":"sqlTypeOther","length":100,"domain":null,"defaultValue":null},{"name":"QUAD_NO","type":"esriFieldTypeDouble","alias":"QUAD_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"TOWN_NO","type":"esriFieldTypeDouble","alias":"TOWN_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"TOWN","type":"esriFieldTypeString","alias":"TOWN","sqlType":"sqlTypeOther","length":150,"domain":null,"defaultValue":null},{"name":"OWNER","type":"esriFieldTypeString","alias":"OWNER","sqlType":"sqlTypeOther","length":2,"domain":null,"defaultValue":null},{"name":"SBAS_NO","type":"esriFieldTypeDouble","alias":"SBAS_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"RBAS_NO","type":"esriFieldTypeDouble","alias":"RBAS_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"MBAS_NO","type":"esriFieldTypeDouble","alias":"MBAS_NO","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"DAM_STATUS","type":"esriFieldTypeString","alias":"DAM_STATUS","sqlType":"sqlTypeOther","length":30,"domain":null,"defaultValue":null},{"name":"LONGITUDE","type":"esriFieldTypeDouble","alias":"LONGITUDE","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"LATITUDE","type":"esriFieldTypeDouble","alias":"LATITUDE","sqlType":"sqlTypeOther","domain":null,"defaultValue":null},{"name":"DAM_HAZ","type":"esriFieldTypeString","alias":"DAM_HAZ","sqlType":"sqlTypeOther","length":50,"domain":null,"defaultValue":null}],"features":[{"attributes":{"OBJECTID":324,"OBJECTID_1":330,"DAM_NO":16005,"DAM_NAME":"BISSONETTE POND DAM","ALT_NAME":"BISSONETTE POND DAM","QUAD_NO":26,"TOWN_NO":160,"TOWN":"WILLINGTON","OWNER":"P","SBAS_NO":3207,"RBAS_NO":32,"MBAS_NO":3,"DAM_STATUS":"Active In Use","LONGITUDE":-72.22040738,"LATITUDE":41.92256498,"DAM_HAZ":"BB"},"geometry":{"x":-72.220408324092915,"y":41.922573533925}},{"attributes":{"OBJECTID":289,"OBJECTID_1":294,"DAM_NO":16011,"DAM_NAME":"HERB HARRISON DAM","ALT_NAME":"HARRISON DAM","QUAD_NO":26,"TOWN_NO":160,"TOWN":"WILLINGTON","OWNER":"P","SBAS_NO":3104,"RBAS_NO":31,"MBAS_NO":3,"DAM_STATUS":"Unknown","LONGITUDE":-72.2455798,"LATITUDE":41.93181857,"DAM_HAZ":"Unclassified"},"geometry":{"x":-72.245580756670307,"y":41.931827124605555}},{"attributes":{"OBJECTID":334,"OBJECTID_1":340,"DAM_NO":16017,"DAM_NAME":"TURNPIKE ROAD POND DAM","ALT_NAME":"TURNPIKE ROAD POND DAM","QUAD_NO":26,"TOWN_NO":160,"TOWN":"WILLINGTON","OWNER":"P","SBAS_NO":3207,"RBAS_NO":32,"MBAS_NO":3,"DAM_STATUS":"Active In Use","LONGITUDE":-72.22213945,"LATITUDE":41.91773622,"DAM_HAZ":"BB"},"geometry":{"x":-72.222140390433651,"y":41.91774477200709}},{"attributes":{"OBJECTID":259,"OBJECTID_1":263,"DAM_NO":311,"DAM_NAME":"ARMITAGE POND DAM","ALT_NAME":"ARMITAGE POND DAM","QUAD_NO":26,"TOWN_NO":3,"TOWN":"ASHFORD","OWNER":"P","SBAS_NO":3207,"RBAS_NO":32,"MBAS_NO":3,"DAM_STATUS":"Active In Use","LONGITUDE":-72.20298524,"LATITUDE":41.94417567,"DAM_HAZ":"BB"},"geometry":{"x":-72.2029861785775,"y":41.944184231484023}}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

View file

@ -62,6 +62,22 @@
{
"path": "terrain/terrain-data.json",
"sha256": "46abaeb872b0a3a8688f53a776dcc2a33341b28dfe6cf556717a6d797d7e1f2b"
},
{
"path": "terrain/aerial-1951.jpg",
"sha256": "a7c9b75c5aa4cc74a2668dccbeec5817e005d1aaf5fab953b5ed9048fe539e08"
},
{
"path": "terrain/aerial-1965.jpg",
"sha256": "99908d2d92894547aeb9c05fa29da390e25996cb2e5f29e5e74bb35aa1794e6f"
},
{
"path": "terrain/aerial-1970.jpg",
"sha256": "64bf6d61b4fa81660d426877b8fed44e964be9cccf9f85d4bf9500a3d2451355"
},
{
"path": "terrain/aerial-1986.jpg",
"sha256": "99524aeaccb389fd00fd4f54e37bd88ca41107a955a0585d5e7deda82fb4504c"
}
],
"layers": [
@ -71,7 +87,11 @@
"aerial-1990",
"aerial-1934",
"slope",
"relief"
"relief",
"aerial-1951",
"aerial-1965",
"aerial-1970",
"aerial-1986"
],
"overlays": [
"soil-zones",
@ -79,4 +99,4 @@
"access"
],
"flagCount": 9
}
}

View file

@ -0,0 +1,149 @@
{
"frame": "frames/adimg_37831_13_CNH3H156_1951_s8_pma_1_tf.tif",
"ref": "ref/Ortho_1990.tif",
"coarse": {
"score": 0.23707516491413116,
"m_per_frame_px": 0.6782711867263279,
"rotation_deg": 6.0
},
"ecc": 0.1934784241142153,
"verify_centre": {
"gradient_ncc": 0.036,
"residual_shift_m": 94.1,
"phase_resp": 0.01
},
"coverage_of_grid": 1.0,
"model": "similarity (coarse) + affine (ECC); no relief correction",
"frame_to_ref_px": [
[
0.2193018129984383,
0.025374797007860286,
193.1644507947786
],
[
-0.023951096360513,
0.21983363211821144,
341.50083278731245
],
[
0.0,
0.0,
1.0
]
],
"ref_scale_factor": 0.6,
"scale_table": [
[
0.3,
0.1654544174671173
],
[
0.318,
0.1710798591375351
],
[
0.33708000000000005,
0.1710798591375351
],
[
0.3573048000000001,
0.1710798591375351
],
[
0.3787430880000001,
0.1710798591375351
],
[
0.40146767328000016,
0.1710798591375351
],
[
0.42555573367680016,
0.1710798591375351
],
[
0.4510890776974082,
0.1710798591375351
],
[
0.4781544223592527,
0.1710798591375351
],
[
0.5068436877008079,
0.1710798591375351
],
[
0.5372543089628564,
0.1710798591375351
],
[
0.5694895675006278,
0.1710798591375351
],
[
0.6036589415506656,
0.1710798591375351
],
[
0.6398784780437056,
0.1710798591375351
],
[
0.6782711867263279,
0.23707516491413116
],
[
0.7189674579299076,
0.23707516491413116
],
[
0.7621055054057021,
0.23707516491413116
],
[
0.8078318357300442,
0.23707516491413116
],
[
0.856301745873847,
0.23707516491413116
],
[
0.9076798506262779,
0.23707516491413116
],
[
0.9621406416638546,
0.23707516491413116
],
[
1.0198690801636858,
0.23707516491413116
],
[
1.081061224973507,
0.23707516491413116
],
[
1.1459248984719175,
0.23707516491413116
],
[
1.2146803923802325,
0.23707516491413116
],
[
1.2875612159230465,
0.23707516491413116
],
[
1.3648148888784293,
0.23707516491413116
],
[
1.446703782211135,
0.23707516491413116
]
]
}

View file

@ -0,0 +1,6 @@
2.589090909090909
0
0
-2.5885714285714285
1140657.2945454544
903038.7057142857

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

View file

@ -0,0 +1 @@
PROJCS["NAD_1983_2011_StatePlane_Connecticut_FIPS_0600_Ft_US",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-72.75],PARAMETER["Latitude_Of_Origin",40.8333333333333],UNIT["Foot_US",0.3048006096012192],PARAMETER["Standard_Parallel_1",41.2],PARAMETER["Standard_Parallel_2",41.8666666666667]]

View file

@ -0,0 +1,125 @@
{
"frame": "frames/CTDEP65_37_3031.tif",
"ref": "ref/Ortho_1990.tif",
"coarse": {
"score": 0.3231961131095886,
"m_per_frame_px": 0.26764511552000003,
"rotation_deg": 0.0
},
"ecc": 0.37787868090562093,
"verify_centre": {
"gradient_ncc": 0.063,
"residual_shift_m": 112.4,
"phase_resp": 0.008
},
"coverage_of_grid": 1.0,
"model": "similarity (coarse) + affine (ECC); no relief correction",
"frame_to_ref_px": [
[
0.08955286150121983,
-0.002601668615365176,
391.16610026443993
],
[
0.002482675826686463,
0.08971096050174188,
360.49898743128756
],
[
0.0,
0.0,
1.0
]
],
"ref_scale_factor": 0.6,
"scale_table": [
[
0.2,
0.1304226815700531
],
[
0.21200000000000002,
0.1589784026145935
],
[
0.22472000000000003,
0.1589784026145935
],
[
0.23820320000000003,
0.1589784026145935
],
[
0.25249539200000004,
0.20480071008205414
],
[
0.26764511552000003,
0.3231961131095886
],
[
0.28370382245120007,
0.3231961131095886
],
[
0.3007260517982721,
0.3231961131095886
],
[
0.31876961490616845,
0.3231961131095886
],
[
0.3378957918005386,
0.3231961131095886
],
[
0.35816953930857093,
0.3231961131095886
],
[
0.3796597116670852,
0.3231961131095886
],
[
0.4024392943671103,
0.3231961131095886
],
[
0.42658565202913695,
0.3231961131095886
],
[
0.4521807911508852,
0.3231961131095886
],
[
0.47931163861993836,
0.3231961131095886
],
[
0.5080703369371347,
0.3231961131095886
],
[
0.5385545571533628,
0.3231961131095886
],
[
0.5708678305825645,
0.3231961131095886
],
[
0.6051199004175184,
0.3231961131095886
],
[
0.6414270944425695,
0.3231961131095886
],
[
0.6799127201091237,
0.3231961131095886
]
]
}

View file

@ -0,0 +1,6 @@
2.589090909090909
0
0
-2.5885714285714285
1140657.2945454544
903038.7057142857

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

View file

@ -0,0 +1 @@
PROJCS["NAD_1983_2011_StatePlane_Connecticut_FIPS_0600_Ft_US",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-72.75],PARAMETER["Latitude_Of_Origin",40.8333333333333],UNIT["Foot_US",0.3048006096012192],PARAMETER["Standard_Parallel_1",41.2],PARAMETER["Standard_Parallel_2",41.8666666666667]]

View file

@ -0,0 +1,117 @@
{
"frame": "frames/adimg_37800_00_7ct5799_1970_s20_DPW_1_tf.tif",
"ref": "ref/Ortho_1990.tif",
"coarse": {
"score": 0.25693172216415405,
"m_per_frame_px": 1.0099815680000002,
"rotation_deg": 0.0
},
"ecc": 0.23679170965635113,
"verify_centre": {
"gradient_ncc": 0.005,
"residual_shift_m": 31.6,
"phase_resp": 0.027
},
"coverage_of_grid": 1.0,
"model": "similarity (coarse) + affine (ECC); no relief correction",
"frame_to_ref_px": [
[
0.32473014481601487,
-0.006428295637531772,
532.4490484194102
],
[
0.008798155569090296,
0.3288202903633079,
155.29498359088907
],
[
0.0,
0.0,
1.0
]
],
"ref_scale_factor": 0.6,
"scale_table": [
[
0.8,
0.14492803812026978
],
[
0.8480000000000001,
0.14859849214553833
],
[
0.8988800000000001,
0.15628021955490112
],
[
0.9528128000000001,
0.22893141210079193
],
[
1.0099815680000002,
0.25693172216415405
],
[
1.0705804620800001,
0.25693172216415405
],
[
1.1348152898048003,
0.25693172216415405
],
[
1.2029042071930884,
0.25693172216415405
],
[
1.2750784596246738,
0.25693172216415405
],
[
1.3515831672021543,
0.25693172216415405
],
[
1.4326781572342837,
0.25693172216415405
],
[
1.5186388466683407,
0.25693172216415405
],
[
1.6097571774684412,
0.25693172216415405
],
[
1.7063426081165478,
0.25693172216415405
],
[
1.8087231646035409,
0.25693172216415405
],
[
1.9172465544797535,
0.25693172216415405
],
[
2.0322813477485386,
0.25693172216415405
],
[
2.154218228613451,
0.25693172216415405
],
[
2.283471322330258,
0.25693172216415405
],
[
2.4204796016700736,
0.25693172216415405
]
]
}

View file

@ -0,0 +1,6 @@
2.589090909090909
0
0
-2.5885714285714285
1140657.2945454544
903038.7057142857

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

View file

@ -0,0 +1 @@
PROJCS["NAD_1983_2011_StatePlane_Connecticut_FIPS_0600_Ft_US",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-72.75],PARAMETER["Latitude_Of_Origin",40.8333333333333],UNIT["Foot_US",0.3048006096012192],PARAMETER["Standard_Parallel_1",41.2],PARAMETER["Standard_Parallel_2",41.8666666666667]]

View file

@ -0,0 +1,133 @@
{
"frame": "frames/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_s.tif",
"ref": "ref/Ortho_1990.tif",
"coarse": {
"score": 0.47732970118522644,
"m_per_frame_px": 0.5618000000000001,
"rotation_deg": -2.0
},
"ecc": 0.2903609148839408,
"verify_centre": {
"gradient_ncc": 0.02,
"residual_shift_m": 5.3,
"phase_resp": 0.048
},
"coverage_of_grid": 1.0,
"model": "similarity (coarse) + affine (ECC); no relief correction",
"frame_to_ref_px": [
[
0.18131303461801054,
-0.0071902829626432,
688.2136657836911
],
[
0.007930213378873813,
0.18234098328994824,
351.85724645296295
],
[
0.0,
0.0,
1.0
]
],
"ref_scale_factor": 0.6,
"scale_table": [
[
0.5,
0.31513944268226624
],
[
0.53,
0.38764309883117676
],
[
0.5618000000000001,
0.47732970118522644
],
[
0.5955080000000001,
0.47732970118522644
],
[
0.6312384800000002,
0.47732970118522644
],
[
0.6691127888000002,
0.47732970118522644
],
[
0.7092595561280003,
0.47732970118522644
],
[
0.7518151294956803,
0.47732970118522644
],
[
0.7969240372654212,
0.47732970118522644
],
[
0.8447394795013464,
0.47732970118522644
],
[
0.8954238482714273,
0.47732970118522644
],
[
0.949149279167713,
0.47732970118522644
],
[
1.0060982359177757,
0.47732970118522644
],
[
1.0664641300728424,
0.47732970118522644
],
[
1.1304519778772129,
0.47732970118522644
],
[
1.1982790965498458,
0.47732970118522644
],
[
1.2701758423428366,
0.47732970118522644
],
[
1.346386392883407,
0.47732970118522644
],
[
1.4271695764564114,
0.47732970118522644
],
[
1.5127997510437963,
0.47732970118522644
],
[
1.6035677361064242,
0.47732970118522644
],
[
1.6997818002728098,
0.47732970118522644
],
[
1.8017687082891785,
0.47732970118522644
],
[
1.9098748307865292,
0.47732970118522644
]
]
}

View file

@ -0,0 +1,6 @@
2.589090909090909
0
0
-2.5885714285714285
1140657.2945454544
903038.7057142857

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

View file

@ -0,0 +1 @@
PROJCS["NAD_1983_2011_StatePlane_Connecticut_FIPS_0600_Ft_US",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1000000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-72.75],PARAMETER["Latitude_Of_Origin",40.8333333333333],UNIT["Foot_US",0.3048006096012192],PARAMETER["Standard_Parallel_1",41.2],PARAMETER["Standard_Parallel_2",41.8666666666667]]

View file

@ -768,7 +768,227 @@
0.6096012192024384,
0.6096012192024384
]
},
"aerial-1951": {
"id": "aerial-1951",
"kind": "historical-imagery",
"service": null,
"label": "1951 aerial (frame CNH-3H-156)",
"year": 1951,
"acquired": {
"start": "1951-09-09",
"end": "1951-09-09",
"scope": "single frame date from the MAGIC photo index"
},
"season": "late summer / leaf-on",
"bands": "0",
"status": "downloaded",
"file": "aerial-1951.jpg",
"sourceUrl": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_CNH_Tolland_pma_s8/adimg_37831_13_CNH3H156_1951_s8_pma_1_tf.tif",
"sourceFrame": "CNH-3H-156",
"holder": "UConn MAGIC; USDA PMA flight",
"retrievedAt": "2026-10-08T00:34:17.841355Z",
"sha256": "a7c9b75c5aa4cc74a2668dccbeec5817e005d1aaf5fab953b5ed9048fe539e08",
"bytes": 374831,
"returnedExtent": {
"xmin": 1140656,
"ymin": 899416,
"xmax": 1143504,
"ymax": 903040,
"spatialReference": {
"wkid": 103016,
"latestWkid": 6434
}
},
"width": 1100,
"height": 1400,
"attribution": "UConn Library MAGIC Air Photo Archive / Connecticut State Library; see holder.",
"evidenceKind": "source_observation",
"outputCellSizeUsFeet": [
2.589090909090909,
2.5885714285714285
],
"outputCellSizeMeters": [
0.7891564874038838,
0.7889981494248702
],
"georeferencing": {
"method": "tools/georef_frame.py: unrectified scan registered to the CT ECO Ortho_1990 export by gradient NCC coarse search (scale, rotation, shift) and ECC affine refinement; no relief correction",
"model": "similarity (coarse) + affine (ECC); no relief correction",
"coarseScore": 0.23707516491413116,
"mPerFramePx": 0.6782711867263279,
"rotationDeg": 6.0,
"ecc": 0.1934784241142153,
"checkImage": "evidence/georef-check-1951.png",
"report": "aerial-1951.georef.json"
},
"caveat": "Scanned single frame, affine-registered to 1990 orthophoto: roads and streams line up to roughly 10 m; expect larger error on steep ground and at the frame edges. Not survey-accurate."
},
"aerial-1965": {
"id": "aerial-1965",
"kind": "historical-imagery",
"service": null,
"label": "1965 aerial (frame 03031)",
"year": 1965,
"acquired": {
"start": "1965-04-01",
"end": "1965-04-01",
"scope": "single frame date from the MAGIC photo index"
},
"season": "spring / leaf-off",
"bands": "0",
"status": "downloaded",
"file": "aerial-1965.jpg",
"sourceUrl": "https://ctdigitalarchive.org/_flysystem/repo-bin/2025-01/CTDEP65_37_3031.tif",
"sourceFrame": "03031 (flight line 11)",
"holder": "Connecticut State Library RG 089:11c (Keystone Aerial Survey), via CT Digital Archive",
"retrievedAt": "2026-10-08T00:34:17.841355Z",
"sha256": "99908d2d92894547aeb9c05fa29da390e25996cb2e5f29e5e74bb35aa1794e6f",
"bytes": 607595,
"returnedExtent": {
"xmin": 1140656,
"ymin": 899416,
"xmax": 1143504,
"ymax": 903040,
"spatialReference": {
"wkid": 103016,
"latestWkid": 6434
}
},
"width": 1100,
"height": 1400,
"attribution": "UConn Library MAGIC Air Photo Archive / Connecticut State Library; see holder.",
"evidenceKind": "source_observation",
"outputCellSizeUsFeet": [
2.589090909090909,
2.5885714285714285
],
"outputCellSizeMeters": [
0.7891564874038838,
0.7889981494248702
],
"georeferencing": {
"method": "tools/georef_frame.py: unrectified scan registered to the CT ECO Ortho_1990 export by gradient NCC coarse search (scale, rotation, shift) and ECC affine refinement; no relief correction",
"model": "similarity (coarse) + affine (ECC); no relief correction",
"coarseScore": 0.3231961131095886,
"mPerFramePx": 0.26764511552000003,
"rotationDeg": 0.0,
"ecc": 0.37787868090562093,
"checkImage": "evidence/georef-check-1965.png",
"report": "aerial-1965.georef.json"
},
"caveat": "Scanned single frame, affine-registered to 1990 orthophoto: roads and streams line up to roughly 10 m; expect larger error on steep ground and at the frame edges. Not survey-accurate."
},
"aerial-1970": {
"id": "aerial-1970",
"kind": "historical-imagery",
"service": null,
"label": "1970 aerial (frame 7CT5799)",
"year": 1970,
"acquired": {
"start": "1970-04-16",
"end": "1970-04-16",
"scope": "single frame date from the MAGIC photo index"
},
"season": "spring / leaf-off",
"bands": "0",
"status": "downloaded",
"file": "aerial-1970.jpg",
"sourceUrl": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_7/adimg_37800_00_7ct5799_1970_s20_DPW_1_tf.tif",
"sourceFrame": "7CT5799",
"holder": "UConn MAGIC; CT DPW flight",
"retrievedAt": "2026-10-08T00:34:17.841355Z",
"sha256": "64bf6d61b4fa81660d426877b8fed44e964be9cccf9f85d4bf9500a3d2451355",
"bytes": 334593,
"returnedExtent": {
"xmin": 1140656,
"ymin": 899416,
"xmax": 1143504,
"ymax": 903040,
"spatialReference": {
"wkid": 103016,
"latestWkid": 6434
}
},
"width": 1100,
"height": 1400,
"attribution": "UConn Library MAGIC Air Photo Archive / Connecticut State Library; see holder.",
"evidenceKind": "source_observation",
"outputCellSizeUsFeet": [
2.589090909090909,
2.5885714285714285
],
"outputCellSizeMeters": [
0.7891564874038838,
0.7889981494248702
],
"georeferencing": {
"method": "tools/georef_frame.py: unrectified scan registered to the CT ECO Ortho_1990 export by gradient NCC coarse search (scale, rotation, shift) and ECC affine refinement; no relief correction",
"model": "similarity (coarse) + affine (ECC); no relief correction",
"coarseScore": 0.25693172216415405,
"mPerFramePx": 1.0099815680000002,
"rotationDeg": 0.0,
"ecc": 0.23679170965635113,
"checkImage": "evidence/georef-check-1970.png",
"report": "aerial-1970.georef.json"
},
"caveat": "Scanned single frame, affine-registered to 1990 orthophoto: roads and streams line up to roughly 10 m; expect larger error on steep ground and at the frame edges. Not survey-accurate."
},
"aerial-1986": {
"id": "aerial-1986",
"kind": "historical-imagery",
"service": null,
"label": "1986 aerial (frame 66CT4876)",
"year": 1986,
"acquired": {
"start": "1986-03-22",
"end": "1986-03-22",
"scope": "single frame date from the MAGIC photo index"
},
"season": "late winter / leaf-off, snow patches",
"bands": "0",
"status": "downloaded",
"file": "aerial-1986.jpg",
"sourceUrl": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_s.tif",
"sourceFrame": "66CT4876",
"holder": "UConn MAGIC; CT DEP flight",
"retrievedAt": "2026-10-08T00:34:17.841355Z",
"sha256": "99524aeaccb389fd00fd4f54e37bd88ca41107a955a0585d5e7deda82fb4504c",
"bytes": 458449,
"returnedExtent": {
"xmin": 1140656,
"ymin": 899416,
"xmax": 1143504,
"ymax": 903040,
"spatialReference": {
"wkid": 103016,
"latestWkid": 6434
}
},
"width": 1100,
"height": 1400,
"attribution": "UConn Library MAGIC Air Photo Archive / Connecticut State Library; see holder.",
"evidenceKind": "source_observation",
"outputCellSizeUsFeet": [
2.589090909090909,
2.5885714285714285
],
"outputCellSizeMeters": [
0.7891564874038838,
0.7889981494248702
],
"georeferencing": {
"method": "tools/georef_frame.py: unrectified scan registered to the CT ECO Ortho_1990 export by gradient NCC coarse search (scale, rotation, shift) and ECC affine refinement; no relief correction",
"model": "similarity (coarse) + affine (ECC); no relief correction",
"coarseScore": 0.47732970118522644,
"mPerFramePx": 0.5618000000000001,
"rotationDeg": -2.0,
"ecc": 0.2903609148839408,
"checkImage": "evidence/georef-check-1986.png",
"report": "aerial-1986.georef.json"
},
"caveat": "Scanned single frame, affine-registered to 1990 orthophoto: roads and streams line up to roughly 10 m; expect larger error on steep ground and at the frame edges. Not survey-accurate."
}
},
"finishedAt": "2026-10-05T23:05:04.841Z"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 KiB

View file

@ -0,0 +1,260 @@
[
{
"year": 1951,
"id": 39153009456890,
"scale": "1:20000",
"date": "9/9/1951",
"lon": -72.22525,
"lat": 41.92923,
"dist_m": 422,
"links": {
"PDF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_DPF_Windham_pma_s20/adimg_37831_15_DPF8H211_1951_s20_pma_1_p.pdf",
"TIF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_DPF_Windham_pma_s20/adimg_37831_15_DPF8H211_1951_s20_pma_1_tf.tif"
},
"corners": {
"XUL_COORD": -72.25284,
"YUL_COORD": 41.94975,
"XLR_COORD": -72.19765,
"YLR_COORD": 41.9087
}
},
{
"year": 1951,
"id": 39153018745358,
"scale": "1:8000",
"date": "9/9/1951",
"lon": -72.2247,
"lat": 41.92763,
"dist_m": 581,
"links": {
"PDF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_CNH_Tolland_pma_s8/adimg_37831_13_CNH3H156_1951_s8_pma_1_p.pdf",
"TIF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_CNH_Tolland_pma_s8/adimg_37831_13_CNH3H156_1951_s8_pma_1_tf.tif"
},
"corners": {
"XUL_COORD": -72.25229,
"YUL_COORD": 41.94815,
"XLR_COORD": -72.19711,
"YLR_COORD": 41.90709
}
},
{
"year": 1951,
"id": 39153009982051,
"scale": "1:20000",
"date": "9/9/1951",
"lon": -72.22209,
"lat": 41.92692,
"dist_m": 789,
"links": {
"PDF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_CNH_Tolland_pma_s8/adimg_37831_13_CNH3H156_1951_s8_pma_1_p.pdf",
"TIF": "https://magic.lib.uconn.edu/magic_3/raster/37831/aerial/1951/1951_CNH_Tolland_pma_s8/adimg_37831_13_CNH3H156_1951_s8_pma_1_tf.tif"
},
"corners": {
"XUL_COORD": -72.24968,
"YUL_COORD": 41.94744,
"XLR_COORD": -72.19449,
"YLR_COORD": 41.90638
}
},
{
"year": 1965,
"id": "Aerial survey of Connecticut 1965 photograph 03031",
"scale": "1:18000",
"date": "1965-04-01",
"lon": -72.2219,
"lat": 41.9296,
"dist_m": 643,
"links": {
"Handle": "https://hdl.handle.net/11134/3849623",
"Download_TIF": "https://ctdigitalarchive.org/_flysystem/repo-bin/2025-01/CTDEP65_37_3031.tif",
"Thumbnail": "https://ctdigitalarchive.org/_flysystem/repo-service/2025-01/3849623-Thumbnail%20Image.jpg"
},
"corners": {}
},
{
"year": 1965,
"id": "Aerial survey of Connecticut 1965 photograph 03030",
"scale": "1:18000",
"date": "1965-04-01",
"lon": -72.2438,
"lat": 41.9296,
"dist_m": 1234,
"links": {
"Handle": "https://hdl.handle.net/11134/3849622",
"Download_TIF": "https://ctdigitalarchive.org/_flysystem/repo-bin/2025-01/CTDEP65_37_3030.tif",
"Thumbnail": "https://ctdigitalarchive.org/_flysystem/repo-service/2025-01/3849622-Thumbnail%20Image.jpg"
},
"corners": {}
},
{
"year": 1970,
"id": "7CT5799",
"scale": "1:20000",
"date": "4/16/1970",
"lon": -72.22546,
"lat": 41.93856,
"dist_m": 824,
"links": {
"DOWNLOAD_T": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_7/adimg_37800_00_7ct5799_1970_s20_DPW_1_tf.tif",
"DOWNLOAD_P": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_7/adimg_37800_00_7ct5799_1970_s20_DPW_1_p.pdf"
},
"corners": {
"LR_X": -72.20976,
"LR_Y": 41.92683
}
},
{
"year": 1970,
"id": "8CT6375",
"scale": "1:20000",
"date": "4/16/1970",
"lon": -72.22431,
"lat": 41.92436,
"dist_m": 907,
"links": {
"DOWNLOAD_T": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_8/adimg_37800_00_8ct6375_1970_s20_DPW_1_tf.tif",
"DOWNLOAD_P": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_8/adimg_37800_00_8ct6375_1970_s20_DPW_1_p.pdf"
},
"corners": {
"LR_X": -72.20862,
"LR_Y": 41.91262
}
},
{
"year": 1970,
"id": "7CT5800",
"scale": "1:20000",
"date": "4/16/1970",
"lon": -72.23849,
"lat": 41.93853,
"dist_m": 1085,
"links": {
"DOWNLOAD_T": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_7/adimg_37800_00_7ct5800_1970_s20_DPW_1_tf.tif",
"DOWNLOAD_P": "https://magic.lib.uconn.edu/magic_2/raster/37800/aerial/1970/flight_line_7/adimg_37800_00_7ct5800_1970_s20_DPW_1_p.pdf"
},
"corners": {
"LR_X": -72.22279,
"LR_Y": 41.9268
}
},
{
"year": 1986,
"id": "66CT4876",
"scale": "1:6000",
"date": 19860322,
"lon": -72.22208,
"lat": 41.93426,
"dist_m": 652,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_p.pdf",
"Download_T_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_s.tif",
"Download_P_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4876_1986_s6_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -70.72905,
"YUL_CORD_1": 43.28401,
"XLR_CORD_1": -70.69257,
"YLR_CORD_1": 43.25735
}
},
{
"year": 1986,
"id": "66CT4875",
"scale": "1:6000",
"date": 19860322,
"lon": -72.22208,
"lat": 41.94251,
"dist_m": 1339,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4875_1986_s6_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4875_1986_s6_CTDEP_1_p.pdf",
"Download_T_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4875_1986_s6_CTDEP_1_s.tif",
"Download_P_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_66/adimg_37800_00_66ct4875_1986_s6_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -70.72727,
"YUL_CORD_1": 43.30289,
"XLR_CORD_1": -70.69078,
"YLR_CORD_1": 43.27623
}
},
{
"year": 1986,
"id": "65CT4849",
"scale": "1:6000",
"date": 19860322,
"lon": -72.24614,
"lat": 41.93309,
"dist_m": 1414,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_65/adimg_37800_00_65ct4849_1986_s6_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_65/adimg_37800_00_65ct4849_1986_s6_CTDEP_1_p.pdf",
"Download_T_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_65/adimg_37800_00_65ct4849_1986_s6_CTDEP_1_s.tif",
"Download_P_1": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1986/flight_line_65/adimg_37800_00_65ct4849_1986_s6_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -70.75012,
"YUL_CORD_1": 43.28323,
"XLR_CORD_1": -70.71365,
"YLR_CORD_1": 43.25657
}
},
{
"year": 1990,
"id": "66ct6448",
"scale": "1:1000",
"date": "19900503",
"lon": -72.22243,
"lat": 41.92644,
"dist_m": 806,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_66/adimg_37800_00_66ct6448_1990_s1_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_66/adimg_37800_00_66ct6448_1990_s1_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -72.23906,
"YUL_CORD_1": 41.93885,
"XLR_CORD_1": -72.20578,
"YLR_CORD_1": 41.91401
}
},
{
"year": 1990,
"id": "66ct6447",
"scale": "1:1000",
"date": "19900503",
"lon": -72.22198,
"lat": 41.93771,
"dist_m": 895,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_66/adimg_37800_00_66ct6447_1990_s1_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_66/adimg_37800_00_66ct6447_1990_s1_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -72.23862,
"YUL_CORD_1": 41.95012,
"XLR_CORD_1": -72.20534,
"YLR_CORD_1": 41.92527
}
},
{
"year": 1990,
"id": "65ct6534",
"scale": "1:1000",
"date": "19900503",
"lon": -72.24831,
"lat": 41.92873,
"dist_m": 1618,
"links": {
"Download_T": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_65/adimg_37800_00_65ct6534_1990_s1_CTDEP_1_s.tif",
"Download_P": "https://magic.lib.uconn.edu/magic_3/raster/37800/aerial/1990/flight_line_65/adimg_37800_00_65ct6534_1990_s1_CTDEP_1_p.pdf"
},
"corners": {
"XUL_CORD_1": -72.26493,
"YUL_CORD_1": 41.94114,
"XLR_CORD_1": -72.23167,
"YLR_CORD_1": 41.9163
}
}
]

View file

@ -978,6 +978,42 @@
"acquisitionYear": 1934,
"season": "not established for this crop"
},
{
"id": "aerial-1951",
"file": "aerial-1951.jpg",
"worldFile": "aerial-1951.jgw",
"projectionFile": "aerial-1951.prj",
"acquisitionYear": 1951,
"season": "late summer / leaf-on",
"georeferenced": "affine registration to 1990 orthophoto, see collection.json"
},
{
"id": "aerial-1965",
"file": "aerial-1965.jpg",
"worldFile": "aerial-1965.jgw",
"projectionFile": "aerial-1965.prj",
"acquisitionYear": 1965,
"season": "spring / leaf-off",
"georeferenced": "affine registration to 1990 orthophoto, see collection.json"
},
{
"id": "aerial-1970",
"file": "aerial-1970.jpg",
"worldFile": "aerial-1970.jgw",
"projectionFile": "aerial-1970.prj",
"acquisitionYear": 1970,
"season": "spring / leaf-off",
"georeferenced": "affine registration to 1990 orthophoto, see collection.json"
},
{
"id": "aerial-1986",
"file": "aerial-1986.jpg",
"worldFile": "aerial-1986.jgw",
"projectionFile": "aerial-1986.prj",
"acquisitionYear": 1986,
"season": "late winter / leaf-off, snow patches",
"georeferenced": "affine registration to 1990 orthophoto, see collection.json"
},
{
"id": "aerial-1990",
"file": "aerial-1990.jpg",
@ -1160,7 +1196,7 @@
},
"properties": {
"kind": "frontage",
"label": "Potter School Road — northern neck",
"label": "Potter School Road \u2014 northern neck",
"geometryStatus": "approximate",
"reportedLengthFeet": 95,
"basis": "Agent-selected outer-ring GIS boundary vertices (zero-based) 80, 0, 1 after comparison with the cited road map and cached CT ECO 2023 spring imagery. Endpoints are estimates, not derived from a recorded frontage survey.",
@ -1215,7 +1251,7 @@
},
"properties": {
"kind": "frontage",
"label": "Fenton Bluffs Road — eastern road contact",
"label": "Fenton Bluffs Road \u2014 eastern road contact",
"geometryStatus": "approximate",
"reportedLengthFeet": 217,
"basis": "Agent-selected outer-ring GIS boundary vertices (zero-based) 48, 49, 50, 51 after comparison with the cited road map and cached CT ECO 2023 spring imagery. Endpoints are estimates, not derived from a recorded frontage survey.",
@ -1247,4 +1283,4 @@
],
"limitations": "Frontage highlights are source-based location references, not surveyed frontage or proof of legal access. An unlocated right-of-way is listed without drawing a route. No mapped easement does not mean no easements exist."
}
}
}

71
tools/README.md Normal file
View file

@ -0,0 +1,71 @@
# 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/`.

112
tools/georef_frame.py Executable file
View file

@ -0,0 +1,112 @@
#!/usr/bin/env -S uv run --no-project --with opencv-python-headless --with numpy --with pillow python3 -I
"""
Georeference an unrectified historical aerial frame (MAGIC / CT State Library scan) against a georeferenced
reference image (a CT ECO export in EPSG:6434 described by ref.json: {"bbox":[x0,y0,x1,y1],"size":N}) and
warp it onto a property's viewer grid (envelope and cell size of an existing aerial-*.jgw). Writes
<out>.jpg/.jgw/.prj and <out>.georef.json.
Method:
1. coarse: blurred gradient-magnitude images; brute-force sweep over scale (m per frame px) and rotation;
the central part of the frame is slid over the reference with normalized cross-correlation
(cv2.matchTemplate TM_CCOEFF_NORMED), which gives scores comparable across scales;
2. fine: ECC affine refinement on gradient images;
3. verify: residual shift of the output against the template image around the grid centre (phase
correlation) and the NCC of the gradients there. Both go in the report; the residual is in metres.
No relief correction. On hilly ground expect several metres of error away from the matched features.
"""
import argparse, json, sys
import numpy as np, cv2
from PIL import Image
Image.MAX_IMAGE_PIXELS = None
def load_gray(path):
im = Image.open(path)
if im.mode != "L": im = im.convert("L")
return np.array(im)
def grad(a, sigma):
a = cv2.GaussianBlur(a.astype(np.float32), (0, 0), sigma)
gx = cv2.Sobel(a, cv2.CV_32F, 1, 0); gy = cv2.Sobel(a, cv2.CV_32F, 0, 1)
g = np.sqrt(gx * gx + gy * gy); g = g / (np.percentile(g, 99) + 1e-6)
return np.clip(g, 0, 1).astype(np.float32)
def rotate(img, angle):
h, w = img.shape; M = cv2.getRotationMatrix2D((w / 2, h / 2), angle, 1.0)
cos, sin = abs(M[0, 0]), abs(M[0, 1]); nw, nh = int(h * sin + w * cos), int(h * cos + w * sin)
M[0, 2] += nw / 2 - w / 2; M[1, 2] += nh / 2 - h / 2
return cv2.warpAffine(img, M, (nw, nh), flags=cv2.INTER_LINEAR), M
def main():
p = argparse.ArgumentParser()
p.add_argument("--frame", required=True); p.add_argument("--ref", required=True); p.add_argument("--refmeta", required=True)
p.add_argument("--template", required=True); p.add_argument("--prj", required=True); p.add_argument("--out", required=True)
p.add_argument("--scales", default="0.3:3.0"); p.add_argument("--angles", default="-6:6:1")
p.add_argument("--coarse-px", type=int, default=500); p.add_argument("--fine-px", type=int, default=1800)
p.add_argument("--check", default=None); p.add_argument("--min-score", type=float, default=0.0)
a = p.parse_args()
meta = json.load(open(a.refmeta)); x0, y0, x1, y1 = meta["bbox"]; N = meta["size"]
ref_ft_px = (x1 - x0) / N; ref_m_px = ref_ft_px * 0.3048006096
ref_full = load_gray(a.ref); frame_full = load_gray(a.frame)
# ---- coarse ------------------------------------------------------------------------------------
c = a.coarse_px / N; ref_c = cv2.resize(ref_full, None, fx=c, fy=c, interpolation=cv2.INTER_AREA)
ref_g = grad(ref_c, 2.0); coarse_m_px = ref_m_px / c
lo, hi = [float(v) for v in a.scales.split(":")]; scales = []; v = lo
while v <= hi * 1.0001: scales.append(v); v *= 1.06
alo, ahi, ast = [float(v) for v in a.angles.split(":")]; angles = np.arange(alo, ahi + 1e-9, ast)
best = None; table = []
for mpp in scales:
s = mpp / coarse_m_px
fr = cv2.resize(frame_full, None, fx=s, fy=s, interpolation=cv2.INTER_AREA)
for ang in angles:
fr_r, M = rotate(fr, ang); fg = grad(fr_r, 2.0)
h, w = fg.shape; th, tw = min(h, int(ref_g.shape[0] * 0.8)), min(w, int(ref_g.shape[1] * 0.8))
oy, ox = (h - th) // 2, (w - tw) // 2; tpl = fg[oy:oy + th, ox:ox + tw]
if th < 40 or tw < 40: continue
r = cv2.matchTemplate(ref_g, tpl, cv2.TM_CCOEFF_NORMED); _, score, _, loc = cv2.minMaxLoc(r)
if best is None or score > best["score"]:
best = dict(score=float(score), mpp=mpp, ang=float(ang), s=s, M=M, oy=oy, ox=ox, loc=loc)
table.append((mpp, best["score"]))
print(f" scale {mpp:.2f} m/px -> best so far {best['score']:.3f} at {best['mpp']:.2f} m/px {best['ang']:+.0f} deg", file=sys.stderr)
if best["score"] < a.min_score: sys.exit(f"coarse score {best['score']:.3f} below {a.min_score}; refusing to write")
print(f"coarse: {best['mpp']:.3f} m/px, {best['ang']:+.1f} deg, score {best['score']:.3f}", file=sys.stderr)
S = np.array([[best["s"], 0, 0], [0, best["s"], 0], [0, 0, 1]], np.float64); R = np.vstack([best["M"], [0, 0, 1]])
Crop = np.array([[1, 0, -best["ox"]], [0, 1, -best["oy"]], [0, 0, 1]], np.float64)
Place = np.array([[1, 0, best["loc"][0]], [0, 1, best["loc"][1]], [0, 0, 1]], np.float64)
T_frame_to_refc = Place @ Crop @ R @ S
# ---- fine (ECC affine) -------------------------------------------------------------------------
f = min(1.0, a.fine_px / N); ref_f = cv2.resize(ref_full, None, fx=f, fy=f, interpolation=cv2.INTER_AREA); ref_fg = grad(ref_f, 1.2)
Up = np.array([[f / c, 0, 0], [0, f / c, 0], [0, 0, 1]], np.float64); T0 = Up @ T_frame_to_refc
pre = cv2.warpPerspective(frame_full, T0, (ref_f.shape[1], ref_f.shape[0]), flags=cv2.INTER_AREA)
pre_g = grad(pre, 1.2); maskv = cv2.erode((pre > 0).astype(np.uint8), np.ones((15, 15), np.uint8))
warp = np.eye(2, 3, dtype=np.float32); ecc = None
try:
ecc, warp = cv2.findTransformECC(ref_fg, pre_g, warp, cv2.MOTION_AFFINE, (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 300, 1e-7), maskv, 7)
ecc = float(ecc)
except cv2.error as e:
print("ECC refinement failed; keeping the coarse solution", file=sys.stderr)
Wa = np.vstack([warp, [0, 0, 1]]).astype(np.float64); T_frame_to_reff = np.linalg.inv(Wa) @ T0
# ---- compose to the viewer grid ----------------------------------------------------------------
A, D, B, E, C, F = [float(v) for v in open(a.template).read().split()]
tmpl = np.array(Image.open(a.template[:-4] + ".jpg").convert("L")); Hh, W = tmpl.shape
reff2world = np.array([[ref_ft_px / f, 0, x0], [0, -ref_ft_px / f, y1], [0, 0, 1]])
world2out = np.array([[1 / A, 0, -C / A], [0, 1 / E, -F / E], [0, 0, 1]])
Mout = world2out @ reff2world @ T_frame_to_reff
out = cv2.warpPerspective(frame_full, Mout, (W, Hh), flags=cv2.INTER_AREA, borderValue=0)
# ---- verify against the template around the grid centre ---------------------------------------
og, tg = grad(out, 1.5), grad(tmpl, 1.5); cy, cx = Hh // 2, W // 2; r = min(Hh, W) // 3
ow, tw_ = og[cy - r:cy + r, cx - r:cx + r], tg[cy - r:cy + r, cx - r:cx + r]
ncc = float(np.corrcoef(ow.ravel(), tw_.ravel())[0, 1]) if ow.std() > 0 else 0.0
(sx, sy), resp = cv2.phaseCorrelate(tw_, ow); shift_m = float(np.hypot(sx * A, sy * A) * 0.3048006096)
print(f"fine: ECC {ecc if ecc is not None else float('nan'):.3f}; verify: gradient NCC {ncc:.3f}, residual shift {shift_m:.1f} m (resp {resp:.3f})", file=sys.stderr)
Image.fromarray(out).save(a.out + ".jpg", quality=90)
open(a.out + ".jgw", "w").write(open(a.template).read()); open(a.out + ".prj", "w").write(open(a.prj).read())
report = {"frame": a.frame, "ref": a.ref, "coarse": {"score": best["score"], "m_per_frame_px": best["mpp"], "rotation_deg": best["ang"]}, "ecc": ecc,
"verify_centre": {"gradient_ncc": round(ncc, 3), "residual_shift_m": round(shift_m, 1), "phase_resp": round(float(resp), 3)},
"coverage_of_grid": round(float((out > 0).mean()), 3), "model": "similarity (coarse) + affine (ECC); no relief correction",
"frame_to_ref_px": T_frame_to_reff.tolist(), "ref_scale_factor": f, "scale_table": table}
json.dump(report, open(a.out + ".georef.json", "w"), indent=1); print(json.dumps({k: report[k] for k in ("coarse", "ecc", "verify_centre", "coverage_of_grid")}))
if a.check:
tile = 100; yy, xx = np.mgrid[0:Hh, 0:W]; cb = ((yy // tile + xx // tile) % 2).astype(bool)
Image.fromarray(np.where(cb, out, tmpl)).save(a.check)
if __name__ == "__main__": main()