diff --git a/changelog.d/nz-joint-geography-support.added.md b/changelog.d/nz-joint-geography-support.added.md new file mode 100644 index 0000000000..9658958e19 --- /dev/null +++ b/changelog.d/nz-joint-geography-support.added.md @@ -0,0 +1 @@ +Add generated SA1-derived territorial authority × region × Accommodation Supplement area support for NZ. Preserve each of the 67 TA ERP anchors, retain region 99 under its own SA1s, and disclose the 33 unanchored outside-TA Census residents separately. Pin all 29 REGC source pages and add offline regeneration checks; transport activation remains deferred. diff --git a/docs/nz-joint-geography-report.json b/docs/nz-joint-geography-report.json new file mode 100644 index 0000000000..6331014650 --- /dev/null +++ b/docs/nz-joint-geography-report.json @@ -0,0 +1,2027 @@ +{ + "description": "Generated by tools/build_nz_joint_geography.py; Census joint-cell audit, not a transport activation", + "population_basis": "Usable 2023 Census SA1 URP; suppressed/null observations contribute zero under the existing G8-m rule", + "anchor_basis": "Existing 67 real TA ERP references at 30 June 2025; largest-remainder apportionment preserves each TA ERP exactly", + "outside_ta_policy": "TA 999 has no declared ERP anchor; its own Census SA1s remain audit-only and are never reassigned to real TAs", + "sa1_count": 32817, + "census_population": 4993314, + "anchored_census_population": 4993281, + "outside_ta_population": 33, + "atomic_cell_count": 140, + "cells": [ + { + "area": "001|01|2", + "ta_code": "001", + "region_code": "01", + "as_area": 2, + "population": 8382, + "sa1_count": 53 + }, + { + "area": "001|01|3", + "ta_code": "001", + "region_code": "01", + "as_area": 3, + "population": 17388, + "sa1_count": 107 + }, + { + "area": "001|01|4", + "ta_code": "001", + "region_code": "01", + "as_area": 4, + "population": 45597, + "sa1_count": 272 + }, + { + "area": "002|01|2", + "ta_code": "002", + "region_code": "01", + "as_area": 2, + "population": 60330, + "sa1_count": 391 + }, + { + "area": "002|01|4", + "ta_code": "002", + "region_code": "01", + "as_area": 4, + "population": 36273, + "sa1_count": 233 + }, + { + "area": "003|01|2", + "ta_code": "003", + "region_code": "01", + "as_area": 2, + "population": 5292, + "sa1_count": 33 + }, + { + "area": "003|01|3", + "ta_code": "003", + "region_code": "01", + "as_area": 3, + "population": 5022, + "sa1_count": 33 + }, + { + "area": "003|01|4", + "ta_code": "003", + "region_code": "01", + "as_area": 4, + "population": 15585, + "sa1_count": 96 + }, + { + "area": "011|03|2", + "ta_code": "011", + "region_code": "03", + "as_area": 2, + "population": 10077, + "sa1_count": 69 + }, + { + "area": "011|03|3", + "ta_code": "011", + "region_code": "03", + "as_area": 3, + "population": 10413, + "sa1_count": 73 + }, + { + "area": "011|03|4", + "ta_code": "011", + "region_code": "03", + "as_area": 4, + "population": 11517, + "sa1_count": 77 + }, + { + "area": "012|03|2", + "ta_code": "012", + "region_code": "03", + "as_area": 2, + "population": 1158, + "sa1_count": 7 + }, + { + "area": "012|03|3", + "ta_code": "012", + "region_code": "03", + "as_area": 3, + "population": 11475, + "sa1_count": 75 + }, + { + "area": "012|03|4", + "ta_code": "012", + "region_code": "03", + "as_area": 4, + "population": 8673, + "sa1_count": 61 + }, + { + "area": "013|03|1", + "ta_code": "013", + "region_code": "03", + "as_area": 1, + "population": 14595, + "sa1_count": 86 + }, + { + "area": "013|03|2", + "ta_code": "013", + "region_code": "03", + "as_area": 2, + "population": 48648, + "sa1_count": 302 + }, + { + "area": "013|03|3", + "ta_code": "013", + "region_code": "03", + "as_area": 3, + "population": 8232, + "sa1_count": 51 + }, + { + "area": "013|03|4", + "ta_code": "013", + "region_code": "03", + "as_area": 4, + "population": 14463, + "sa1_count": 102 + }, + { + "area": "015|03|2", + "ta_code": "015", + "region_code": "03", + "as_area": 2, + "population": 8865, + "sa1_count": 57 + }, + { + "area": "015|03|3", + "ta_code": "015", + "region_code": "03", + "as_area": 3, + "population": 12888, + "sa1_count": 81 + }, + { + "area": "015|03|4", + "ta_code": "015", + "region_code": "03", + "as_area": 4, + "population": 15372, + "sa1_count": 110 + }, + { + "area": "016|03|2", + "ta_code": "016", + "region_code": "03", + "as_area": 2, + "population": 174768, + "sa1_count": 1097 + }, + { + "area": "017|03|2", + "ta_code": "017", + "region_code": "03", + "as_area": 2, + "population": 47319, + "sa1_count": 327 + }, + { + "area": "017|03|4", + "ta_code": "017", + "region_code": "03", + "as_area": 4, + "population": 11367, + "sa1_count": 70 + }, + { + "area": "018|03|3", + "ta_code": "018", + "region_code": "03", + "as_area": 3, + "population": 2784, + "sa1_count": 18 + }, + { + "area": "018|03|4", + "ta_code": "018", + "region_code": "03", + "as_area": 4, + "population": 7632, + "sa1_count": 47 + }, + { + "area": "019|03|4", + "ta_code": "019", + "region_code": "03", + "as_area": 4, + "population": 25032, + "sa1_count": 166 + }, + { + "area": "020|03|4", + "ta_code": "020", + "region_code": "03", + "as_area": 4, + "population": 9534, + "sa1_count": 69 + }, + { + "area": "020|08|4", + "ta_code": "020", + "region_code": "08", + "as_area": 4, + "population": 45, + "sa1_count": 1 + }, + { + "area": "021|03|2", + "ta_code": "021", + "region_code": "03", + "as_area": 2, + "population": 26082, + "sa1_count": 179 + }, + { + "area": "021|03|4", + "ta_code": "021", + "region_code": "03", + "as_area": 4, + "population": 14016, + "sa1_count": 102 + }, + { + "area": "021|04|4", + "ta_code": "021", + "region_code": "04", + "as_area": 4, + "population": 123, + "sa1_count": 1 + }, + { + "area": "021|06|4", + "ta_code": "021", + "region_code": "06", + "as_area": 4, + "population": 84, + "sa1_count": 2 + }, + { + "area": "021|08|4", + "ta_code": "021", + "region_code": "08", + "as_area": 4, + "population": 0, + "sa1_count": 1 + }, + { + "area": "022|04|1", + "ta_code": "022", + "region_code": "04", + "as_area": 1, + "population": 9411, + "sa1_count": 61 + }, + { + "area": "022|04|2", + "ta_code": "022", + "region_code": "04", + "as_area": 2, + "population": 16806, + "sa1_count": 112 + }, + { + "area": "022|04|4", + "ta_code": "022", + "region_code": "04", + "as_area": 4, + "population": 30000, + "sa1_count": 198 + }, + { + "area": "023|04|1", + "ta_code": "023", + "region_code": "04", + "as_area": 1, + "population": 152493, + "sa1_count": 955 + }, + { + "area": "023|04|4", + "ta_code": "023", + "region_code": "04", + "as_area": 4, + "population": 309, + "sa1_count": 5 + }, + { + "area": "024|03|4", + "ta_code": "024", + "region_code": "03", + "as_area": 4, + "population": 3888, + "sa1_count": 27 + }, + { + "area": "024|04|3", + "ta_code": "024", + "region_code": "04", + "as_area": 3, + "population": 60357, + "sa1_count": 404 + }, + { + "area": "024|04|4", + "ta_code": "024", + "region_code": "04", + "as_area": 4, + "population": 9828, + "sa1_count": 79 + }, + { + "area": "025|04|3", + "ta_code": "025", + "region_code": "04", + "as_area": 3, + "population": 21876, + "sa1_count": 149 + }, + { + "area": "025|04|4", + "ta_code": "025", + "region_code": "04", + "as_area": 4, + "population": 15285, + "sa1_count": 104 + }, + { + "area": "026|04|4", + "ta_code": "026", + "region_code": "04", + "as_area": 4, + "population": 7542, + "sa1_count": 51 + }, + { + "area": "027|04|4", + "ta_code": "027", + "region_code": "04", + "as_area": 4, + "population": 10098, + "sa1_count": 61 + }, + { + "area": "028|05|3", + "ta_code": "028", + "region_code": "05", + "as_area": 3, + "population": 38445, + "sa1_count": 231 + }, + { + "area": "028|05|4", + "ta_code": "028", + "region_code": "05", + "as_area": 4, + "population": 12684, + "sa1_count": 77 + }, + { + "area": "029|06|4", + "ta_code": "029", + "region_code": "06", + "as_area": 4, + "population": 8811, + "sa1_count": 61 + }, + { + "area": "030|06|2", + "ta_code": "030", + "region_code": "06", + "as_area": 2, + "population": 76101, + "sa1_count": 496 + }, + { + "area": "030|06|4", + "ta_code": "030", + "region_code": "06", + "as_area": 4, + "population": 9867, + "sa1_count": 66 + }, + { + "area": "031|06|2", + "ta_code": "031", + "region_code": "06", + "as_area": 2, + "population": 64668, + "sa1_count": 422 + }, + { + "area": "032|06|3", + "ta_code": "032", + "region_code": "06", + "as_area": 3, + "population": 2334, + "sa1_count": 14 + }, + { + "area": "032|06|4", + "ta_code": "032", + "region_code": "06", + "as_area": 4, + "population": 13155, + "sa1_count": 86 + }, + { + "area": "033|07|2", + "ta_code": "033", + "region_code": "07", + "as_area": 2, + "population": 61302, + "sa1_count": 401 + }, + { + "area": "033|07|3", + "ta_code": "033", + "region_code": "07", + "as_area": 3, + "population": 10776, + "sa1_count": 68 + }, + { + "area": "033|07|4", + "ta_code": "033", + "region_code": "07", + "as_area": 4, + "population": 14886, + "sa1_count": 93 + }, + { + "area": "034|07|4", + "ta_code": "034", + "region_code": "07", + "as_area": 4, + "population": 9981, + "sa1_count": 71 + }, + { + "area": "034|08|4", + "ta_code": "034", + "region_code": "08", + "as_area": 4, + "population": 159, + "sa1_count": 1 + }, + { + "area": "035|07|3", + "ta_code": "035", + "region_code": "07", + "as_area": 3, + "population": 12882, + "sa1_count": 84 + }, + { + "area": "035|07|4", + "ta_code": "035", + "region_code": "07", + "as_area": 4, + "population": 16158, + "sa1_count": 114 + }, + { + "area": "036|08|4", + "ta_code": "036", + "region_code": "08", + "as_area": 4, + "population": 13089, + "sa1_count": 96 + }, + { + "area": "037|08|4", + "ta_code": "037", + "region_code": "08", + "as_area": 4, + "population": 47622, + "sa1_count": 310 + }, + { + "area": "038|06|4", + "ta_code": "038", + "region_code": "06", + "as_area": 4, + "population": 24, + "sa1_count": 1 + }, + { + "area": "038|08|4", + "ta_code": "038", + "region_code": "08", + "as_area": 4, + "population": 15660, + "sa1_count": 110 + }, + { + "area": "039|08|3", + "ta_code": "039", + "region_code": "08", + "as_area": 3, + "population": 22668, + "sa1_count": 151 + }, + { + "area": "039|08|4", + "ta_code": "039", + "region_code": "08", + "as_area": 4, + "population": 9762, + "sa1_count": 82 + }, + { + "area": "040|08|3", + "ta_code": "040", + "region_code": "08", + "as_area": 3, + "population": 83991, + "sa1_count": 564 + }, + { + "area": "040|08|4", + "ta_code": "040", + "region_code": "08", + "as_area": 4, + "population": 3150, + "sa1_count": 21 + }, + { + "area": "041|08|4", + "ta_code": "041", + "region_code": "08", + "as_area": 4, + "population": 18660, + "sa1_count": 123 + }, + { + "area": "041|09|4", + "ta_code": "041", + "region_code": "09", + "as_area": 4, + "population": 6, + "sa1_count": 1 + }, + { + "area": "042|08|3", + "ta_code": "042", + "region_code": "08", + "as_area": 3, + "population": 26037, + "sa1_count": 157 + }, + { + "area": "042|08|4", + "ta_code": "042", + "region_code": "08", + "as_area": 4, + "population": 10668, + "sa1_count": 67 + }, + { + "area": "043|09|2", + "ta_code": "043", + "region_code": "09", + "as_area": 2, + "population": 44055, + "sa1_count": 315 + }, + { + "area": "043|09|3", + "ta_code": "043", + "region_code": "09", + "as_area": 3, + "population": 8265, + "sa1_count": 62 + }, + { + "area": "043|09|4", + "ta_code": "043", + "region_code": "09", + "as_area": 4, + "population": 3594, + "sa1_count": 27 + }, + { + "area": "044|09|2", + "ta_code": "044", + "region_code": "09", + "as_area": 2, + "population": 59202, + "sa1_count": 406 + }, + { + "area": "044|09|3", + "ta_code": "044", + "region_code": "09", + "as_area": 3, + "population": 204, + "sa1_count": 3 + }, + { + "area": "045|09|2", + "ta_code": "045", + "region_code": "09", + "as_area": 2, + "population": 43233, + "sa1_count": 275 + }, + { + "area": "045|09|3", + "ta_code": "045", + "region_code": "09", + "as_area": 3, + "population": 2526, + "sa1_count": 18 + }, + { + "area": "046|09|2", + "ta_code": "046", + "region_code": "09", + "as_area": 2, + "population": 106869, + "sa1_count": 728 + }, + { + "area": "046|09|3", + "ta_code": "046", + "region_code": "09", + "as_area": 3, + "population": 687, + "sa1_count": 7 + }, + { + "area": "047|09|2", + "ta_code": "047", + "region_code": "09", + "as_area": 2, + "population": 202662, + "sa1_count": 1416 + }, + { + "area": "048|09|3", + "ta_code": "048", + "region_code": "09", + "as_area": 3, + "population": 23928, + "sa1_count": 155 + }, + { + "area": "048|09|4", + "ta_code": "048", + "region_code": "09", + "as_area": 4, + "population": 3741, + "sa1_count": 26 + }, + { + "area": "049|09|3", + "ta_code": "049", + "region_code": "09", + "as_area": 3, + "population": 5739, + "sa1_count": 36 + }, + { + "area": "049|09|4", + "ta_code": "049", + "region_code": "09", + "as_area": 4, + "population": 4383, + "sa1_count": 28 + }, + { + "area": "050|09|3", + "ta_code": "050", + "region_code": "09", + "as_area": 3, + "population": 4482, + "sa1_count": 32 + }, + { + "area": "050|09|4", + "ta_code": "050", + "region_code": "09", + "as_area": 4, + "population": 7317, + "sa1_count": 50 + }, + { + "area": "051|16|2", + "ta_code": "051", + "region_code": "16", + "as_area": 2, + "population": 35052, + "sa1_count": 255 + }, + { + "area": "051|16|3", + "ta_code": "051", + "region_code": "16", + "as_area": 3, + "population": 1389, + "sa1_count": 10 + }, + { + "area": "051|16|4", + "ta_code": "051", + "region_code": "16", + "as_area": 4, + "population": 21417, + "sa1_count": 145 + }, + { + "area": "052|17|2", + "ta_code": "052", + "region_code": "17", + "as_area": 2, + "population": 51225, + "sa1_count": 391 + }, + { + "area": "052|17|4", + "ta_code": "052", + "region_code": "17", + "as_area": 4, + "population": 1272, + "sa1_count": 8 + }, + { + "area": "053|18|2", + "ta_code": "053", + "region_code": "18", + "as_area": 2, + "population": 34410, + "sa1_count": 239 + }, + { + "area": "053|18|3", + "ta_code": "053", + "region_code": "18", + "as_area": 3, + "population": 4722, + "sa1_count": 33 + }, + { + "area": "053|18|4", + "ta_code": "053", + "region_code": "18", + "as_area": 4, + "population": 10233, + "sa1_count": 89 + }, + { + "area": "054|13|3", + "ta_code": "054", + "region_code": "13", + "as_area": 3, + "population": 2199, + "sa1_count": 15 + }, + { + "area": "054|13|4", + "ta_code": "054", + "region_code": "13", + "as_area": 4, + "population": 2016, + "sa1_count": 13 + }, + { + "area": "055|12|4", + "ta_code": "055", + "region_code": "12", + "as_area": 4, + "population": 10440, + "sa1_count": 73 + }, + { + "area": "056|12|3", + "ta_code": "056", + "region_code": "12", + "as_area": 3, + "population": 9489, + "sa1_count": 69 + }, + { + "area": "056|12|4", + "ta_code": "056", + "region_code": "12", + "as_area": 4, + "population": 4530, + "sa1_count": 29 + }, + { + "area": "057|12|3", + "ta_code": "057", + "region_code": "12", + "as_area": 3, + "population": 3555, + "sa1_count": 26 + }, + { + "area": "057|12|4", + "ta_code": "057", + "region_code": "12", + "as_area": 4, + "population": 5337, + "sa1_count": 49 + }, + { + "area": "058|13|2", + "ta_code": "058", + "region_code": "13", + "as_area": 2, + "population": 2427, + "sa1_count": 17 + }, + { + "area": "058|13|3", + "ta_code": "058", + "region_code": "13", + "as_area": 3, + "population": 960, + "sa1_count": 8 + }, + { + "area": "058|13|4", + "ta_code": "058", + "region_code": "13", + "as_area": 4, + "population": 10197, + "sa1_count": 72 + }, + { + "area": "059|13|2", + "ta_code": "059", + "region_code": "13", + "as_area": 2, + "population": 39675, + "sa1_count": 284 + }, + { + "area": "059|13|4", + "ta_code": "059", + "region_code": "13", + "as_area": 4, + "population": 26562, + "sa1_count": 177 + }, + { + "area": "060|13|2", + "ta_code": "060", + "region_code": "13", + "as_area": 2, + "population": 388068, + "sa1_count": 2580 + }, + { + "area": "060|13|4", + "ta_code": "060", + "region_code": "13", + "as_area": 4, + "population": 3309, + "sa1_count": 27 + }, + { + "area": "062|13|2", + "ta_code": "062", + "region_code": "13", + "as_area": 2, + "population": 49464, + "sa1_count": 338 + }, + { + "area": "062|13|4", + "ta_code": "062", + "region_code": "13", + "as_area": 4, + "population": 28659, + "sa1_count": 183 + }, + { + "area": "063|13|2", + "ta_code": "063", + "region_code": "13", + "as_area": 2, + "population": 21714, + "sa1_count": 149 + }, + { + "area": "063|13|3", + "ta_code": "063", + "region_code": "13", + "as_area": 3, + "population": 1596, + "sa1_count": 11 + }, + { + "area": "063|13|4", + "ta_code": "063", + "region_code": "13", + "as_area": 4, + "population": 11436, + "sa1_count": 81 + }, + { + "area": "064|13|3", + "ta_code": "064", + "region_code": "13", + "as_area": 3, + "population": 36402, + "sa1_count": 268 + }, + { + "area": "064|13|4", + "ta_code": "064", + "region_code": "13", + "as_area": 4, + "population": 11154, + "sa1_count": 85 + }, + { + "area": "065|13|3", + "ta_code": "065", + "region_code": "13", + "as_area": 3, + "population": 1491, + "sa1_count": 15 + }, + { + "area": "065|13|4", + "ta_code": "065", + "region_code": "13", + "as_area": 4, + "population": 3630, + "sa1_count": 32 + }, + { + "area": "066|13|4", + "ta_code": "066", + "region_code": "13", + "as_area": 4, + "population": 8106, + "sa1_count": 56 + }, + { + "area": "067|99|4", + "ta_code": "067", + "region_code": "99", + "as_area": 4, + "population": 612, + "sa1_count": 7 + }, + { + "area": "068|13|4", + "ta_code": "068", + "region_code": "13", + "as_area": 4, + "population": 1896, + "sa1_count": 17 + }, + { + "area": "068|14|3", + "ta_code": "068", + "region_code": "14", + "as_area": 3, + "population": 14403, + "sa1_count": 97 + }, + { + "area": "068|14|4", + "ta_code": "068", + "region_code": "14", + "as_area": 4, + "population": 7158, + "sa1_count": 46 + }, + { + "area": "069|14|2", + "ta_code": "069", + "region_code": "14", + "as_area": 2, + "population": 6339, + "sa1_count": 43 + }, + { + "area": "069|14|3", + "ta_code": "069", + "region_code": "14", + "as_area": 3, + "population": 5598, + "sa1_count": 38 + }, + { + "area": "069|14|4", + "ta_code": "069", + "region_code": "14", + "as_area": 4, + "population": 12378, + "sa1_count": 75 + }, + { + "area": "070|14|1", + "ta_code": "070", + "region_code": "14", + "as_area": 1, + "population": 27621, + "sa1_count": 223 + }, + { + "area": "070|14|4", + "ta_code": "070", + "region_code": "14", + "as_area": 4, + "population": 20199, + "sa1_count": 147 + }, + { + "area": "071|14|3", + "ta_code": "071", + "region_code": "14", + "as_area": 3, + "population": 120681, + "sa1_count": 794 + }, + { + "area": "071|14|4", + "ta_code": "071", + "region_code": "14", + "as_area": 4, + "population": 8187, + "sa1_count": 55 + }, + { + "area": "072|14|4", + "ta_code": "072", + "region_code": "14", + "as_area": 4, + "population": 18321, + "sa1_count": 122 + }, + { + "area": "073|15|3", + "ta_code": "073", + "region_code": "15", + "as_area": 3, + "population": 2472, + "sa1_count": 17 + }, + { + "area": "073|15|4", + "ta_code": "073", + "region_code": "15", + "as_area": 4, + "population": 29367, + "sa1_count": 255 + }, + { + "area": "074|15|4", + "ta_code": "074", + "region_code": "15", + "as_area": 4, + "population": 12708, + "sa1_count": 87 + }, + { + "area": "075|15|4", + "ta_code": "075", + "region_code": "15", + "as_area": 4, + "population": 55596, + "sa1_count": 398 + }, + { + "area": "076|02|1", + "ta_code": "076", + "region_code": "02", + "as_area": 1, + "population": 1629282, + "sa1_count": 10171 + }, + { + "area": "076|02|2", + "ta_code": "076", + "region_code": "02", + "as_area": 2, + "population": 26274, + "sa1_count": 172 + }, + { + "area": "076|02|4", + "ta_code": "076", + "region_code": "02", + "as_area": 4, + "population": 696, + "sa1_count": 12 + } + ], + "outside_ta_cells": [ + { + "area": "outside-ta|04|4", + "ta_code": "999", + "region_code": "04", + "as_area": 4, + "population": 33, + "sa1_count": 5 + }, + { + "area": "outside-ta|06|4", + "ta_code": "999", + "region_code": "06", + "as_area": 4, + "population": 0, + "sa1_count": 1 + }, + { + "area": "outside-ta|99|4", + "ta_code": "999", + "region_code": "99", + "as_area": 4, + "population": 0, + "sa1_count": 1 + } + ], + "outside_ta_sa1s": [ + { + "sa1_code": "7022479", + "ta_code": "999", + "as_area": 4, + "population": 0, + "region_code": "99" + }, + { + "sa1_code": "7022489", + "ta_code": "999", + "as_area": 4, + "population": 3, + "region_code": "04" + }, + { + "sa1_code": "7022490", + "ta_code": "999", + "as_area": 4, + "population": 30, + "region_code": "04" + }, + { + "sa1_code": "7022491", + "ta_code": "999", + "as_area": 4, + "population": 0, + "region_code": "04" + }, + { + "sa1_code": "7022492", + "ta_code": "999", + "as_area": 4, + "population": 0, + "region_code": "04" + }, + { + "sa1_code": "7022493", + "ta_code": "999", + "as_area": 4, + "population": 0, + "region_code": "04" + }, + { + "sa1_code": "7022500", + "ta_code": "999", + "as_area": 4, + "population": 0, + "region_code": "06" + } + ], + "ta_totals": [ + { + "ta_code": "001", + "target": "stats_nz_population_by_territorial_authority__ta001", + "population_code": "nz-ta-001", + "population": 71367 + }, + { + "ta_code": "002", + "target": "stats_nz_population_by_territorial_authority__ta002", + "population_code": "nz-ta-002", + "population": 96603 + }, + { + "ta_code": "003", + "target": "stats_nz_population_by_territorial_authority__ta003", + "population_code": "nz-ta-003", + "population": 25899 + }, + { + "ta_code": "011", + "target": "stats_nz_population_by_territorial_authority__ta011", + "population_code": "nz-ta-011", + "population": 32007 + }, + { + "ta_code": "012", + "target": "stats_nz_population_by_territorial_authority__ta012", + "population_code": "nz-ta-012", + "population": 21306 + }, + { + "ta_code": "013", + "target": "stats_nz_population_by_territorial_authority__ta013", + "population_code": "nz-ta-013", + "population": 85938 + }, + { + "ta_code": "015", + "target": "stats_nz_population_by_territorial_authority__ta015", + "population_code": "nz-ta-015", + "population": 37125 + }, + { + "ta_code": "016", + "target": "stats_nz_population_by_territorial_authority__ta016", + "population_code": "nz-ta-016", + "population": 174768 + }, + { + "ta_code": "017", + "target": "stats_nz_population_by_territorial_authority__ta017", + "population_code": "nz-ta-017", + "population": 58686 + }, + { + "ta_code": "018", + "target": "stats_nz_population_by_territorial_authority__ta018", + "population_code": "nz-ta-018", + "population": 10416 + }, + { + "ta_code": "019", + "target": "stats_nz_population_by_territorial_authority__ta019", + "population_code": "nz-ta-019", + "population": 25032 + }, + { + "ta_code": "020", + "target": "stats_nz_population_by_territorial_authority__ta020", + "population_code": "nz-ta-020", + "population": 9579 + }, + { + "ta_code": "021", + "target": "stats_nz_population_by_territorial_authority__ta021", + "population_code": "nz-ta-021", + "population": 40305 + }, + { + "ta_code": "022", + "target": "stats_nz_population_by_territorial_authority__ta022", + "population_code": "nz-ta-022", + "population": 56217 + }, + { + "ta_code": "023", + "target": "stats_nz_population_by_territorial_authority__ta023", + "population_code": "nz-ta-023", + "population": 152802 + }, + { + "ta_code": "024", + "target": "stats_nz_population_by_territorial_authority__ta024", + "population_code": "nz-ta-024", + "population": 74073 + }, + { + "ta_code": "025", + "target": "stats_nz_population_by_territorial_authority__ta025", + "population_code": "nz-ta-025", + "population": 37161 + }, + { + "ta_code": "026", + "target": "stats_nz_population_by_territorial_authority__ta026", + "population_code": "nz-ta-026", + "population": 7542 + }, + { + "ta_code": "027", + "target": "stats_nz_population_by_territorial_authority__ta027", + "population_code": "nz-ta-027", + "population": 10098 + }, + { + "ta_code": "028", + "target": "stats_nz_population_by_territorial_authority__ta028", + "population_code": "nz-ta-028", + "population": 51129 + }, + { + "ta_code": "029", + "target": "stats_nz_population_by_territorial_authority__ta029", + "population_code": "nz-ta-029", + "population": 8811 + }, + { + "ta_code": "030", + "target": "stats_nz_population_by_territorial_authority__ta030", + "population_code": "nz-ta-030", + "population": 85968 + }, + { + "ta_code": "031", + "target": "stats_nz_population_by_territorial_authority__ta031", + "population_code": "nz-ta-031", + "population": 64668 + }, + { + "ta_code": "032", + "target": "stats_nz_population_by_territorial_authority__ta032", + "population_code": "nz-ta-032", + "population": 15489 + }, + { + "ta_code": "033", + "target": "stats_nz_population_by_territorial_authority__ta033", + "population_code": "nz-ta-033", + "population": 86964 + }, + { + "ta_code": "034", + "target": "stats_nz_population_by_territorial_authority__ta034", + "population_code": "nz-ta-034", + "population": 10140 + }, + { + "ta_code": "035", + "target": "stats_nz_population_by_territorial_authority__ta035", + "population_code": "nz-ta-035", + "population": 29040 + }, + { + "ta_code": "036", + "target": "stats_nz_population_by_territorial_authority__ta036", + "population_code": "nz-ta-036", + "population": 13089 + }, + { + "ta_code": "037", + "target": "stats_nz_population_by_territorial_authority__ta037", + "population_code": "nz-ta-037", + "population": 47622 + }, + { + "ta_code": "038", + "target": "stats_nz_population_by_territorial_authority__ta038", + "population_code": "nz-ta-038", + "population": 15684 + }, + { + "ta_code": "039", + "target": "stats_nz_population_by_territorial_authority__ta039", + "population_code": "nz-ta-039", + "population": 32430 + }, + { + "ta_code": "040", + "target": "stats_nz_population_by_territorial_authority__ta040", + "population_code": "nz-ta-040", + "population": 87141 + }, + { + "ta_code": "041", + "target": "stats_nz_population_by_territorial_authority__ta041", + "population_code": "nz-ta-041", + "population": 18666 + }, + { + "ta_code": "042", + "target": "stats_nz_population_by_territorial_authority__ta042", + "population_code": "nz-ta-042", + "population": 36705 + }, + { + "ta_code": "043", + "target": "stats_nz_population_by_territorial_authority__ta043", + "population_code": "nz-ta-043", + "population": 55914 + }, + { + "ta_code": "044", + "target": "stats_nz_population_by_territorial_authority__ta044", + "population_code": "nz-ta-044", + "population": 59406 + }, + { + "ta_code": "045", + "target": "stats_nz_population_by_territorial_authority__ta045", + "population_code": "nz-ta-045", + "population": 45759 + }, + { + "ta_code": "046", + "target": "stats_nz_population_by_territorial_authority__ta046", + "population_code": "nz-ta-046", + "population": 107556 + }, + { + "ta_code": "047", + "target": "stats_nz_population_by_territorial_authority__ta047", + "population_code": "nz-ta-047", + "population": 202662 + }, + { + "ta_code": "048", + "target": "stats_nz_population_by_territorial_authority__ta048", + "population_code": "nz-ta-048", + "population": 27669 + }, + { + "ta_code": "049", + "target": "stats_nz_population_by_territorial_authority__ta049", + "population_code": "nz-ta-049", + "population": 10122 + }, + { + "ta_code": "050", + "target": "stats_nz_population_by_territorial_authority__ta050", + "population_code": "nz-ta-050", + "population": 11799 + }, + { + "ta_code": "051", + "target": "stats_nz_population_by_territorial_authority__ta051", + "population_code": "nz-ta-051", + "population": 57858 + }, + { + "ta_code": "052", + "target": "stats_nz_population_by_territorial_authority__ta052", + "population_code": "nz-ta-052", + "population": 52497 + }, + { + "ta_code": "053", + "target": "stats_nz_population_by_territorial_authority__ta053", + "population_code": "nz-ta-053", + "population": 49365 + }, + { + "ta_code": "054", + "target": "stats_nz_population_by_territorial_authority__ta054", + "population_code": "nz-ta-054", + "population": 4215 + }, + { + "ta_code": "055", + "target": "stats_nz_population_by_territorial_authority__ta055", + "population_code": "nz-ta-055", + "population": 10440 + }, + { + "ta_code": "056", + "target": "stats_nz_population_by_territorial_authority__ta056", + "population_code": "nz-ta-056", + "population": 14019 + }, + { + "ta_code": "057", + "target": "stats_nz_population_by_territorial_authority__ta057", + "population_code": "nz-ta-057", + "population": 8892 + }, + { + "ta_code": "058", + "target": "stats_nz_population_by_territorial_authority__ta058", + "population_code": "nz-ta-058", + "population": 13584 + }, + { + "ta_code": "059", + "target": "stats_nz_population_by_territorial_authority__ta059", + "population_code": "nz-ta-059", + "population": 66237 + }, + { + "ta_code": "060", + "target": "stats_nz_population_by_territorial_authority__ta060", + "population_code": "nz-ta-060", + "population": 391377 + }, + { + "ta_code": "062", + "target": "stats_nz_population_by_territorial_authority__ta062", + "population_code": "nz-ta-062", + "population": 78123 + }, + { + "ta_code": "063", + "target": "stats_nz_population_by_territorial_authority__ta063", + "population_code": "nz-ta-063", + "population": 34746 + }, + { + "ta_code": "064", + "target": "stats_nz_population_by_territorial_authority__ta064", + "population_code": "nz-ta-064", + "population": 47556 + }, + { + "ta_code": "065", + "target": "stats_nz_population_by_territorial_authority__ta065", + "population_code": "nz-ta-065", + "population": 5121 + }, + { + "ta_code": "066", + "target": "stats_nz_population_by_territorial_authority__ta066", + "population_code": "nz-ta-066", + "population": 8106 + }, + { + "ta_code": "067", + "target": "stats_nz_population_by_territorial_authority__ta067", + "population_code": "nz-ta-067", + "population": 612 + }, + { + "ta_code": "068", + "target": "stats_nz_population_by_territorial_authority__ta068", + "population_code": "nz-ta-068", + "population": 23457 + }, + { + "ta_code": "069", + "target": "stats_nz_population_by_territorial_authority__ta069", + "population_code": "nz-ta-069", + "population": 24315 + }, + { + "ta_code": "070", + "target": "stats_nz_population_by_territorial_authority__ta070", + "population_code": "nz-ta-070", + "population": 47820 + }, + { + "ta_code": "071", + "target": "stats_nz_population_by_territorial_authority__ta071", + "population_code": "nz-ta-071", + "population": 128868 + }, + { + "ta_code": "072", + "target": "stats_nz_population_by_territorial_authority__ta072", + "population_code": "nz-ta-072", + "population": 18321 + }, + { + "ta_code": "073", + "target": "stats_nz_population_by_territorial_authority__ta073", + "population_code": "nz-ta-073", + "population": 31839 + }, + { + "ta_code": "074", + "target": "stats_nz_population_by_territorial_authority__ta074", + "population_code": "nz-ta-074", + "population": 12708 + }, + { + "ta_code": "075", + "target": "stats_nz_population_by_territorial_authority__ta075", + "population_code": "nz-ta-075", + "population": 55596 + }, + { + "ta_code": "076", + "target": "stats_nz_population_by_territorial_authority__ta076", + "population_code": "nz-ta-076", + "population": 1656252 + } + ], + "straddling_tas": [ + { + "ta_code": "020", + "region_code": "03", + "population": 9534, + "sa1_count": 69 + }, + { + "ta_code": "020", + "region_code": "08", + "population": 45, + "sa1_count": 1 + }, + { + "ta_code": "021", + "region_code": "03", + "population": 40098, + "sa1_count": 281 + }, + { + "ta_code": "021", + "region_code": "04", + "population": 123, + "sa1_count": 1 + }, + { + "ta_code": "021", + "region_code": "06", + "population": 84, + "sa1_count": 2 + }, + { + "ta_code": "021", + "region_code": "08", + "population": 0, + "sa1_count": 1 + }, + { + "ta_code": "024", + "region_code": "03", + "population": 3888, + "sa1_count": 27 + }, + { + "ta_code": "024", + "region_code": "04", + "population": 70185, + "sa1_count": 483 + }, + { + "ta_code": "034", + "region_code": "07", + "population": 9981, + "sa1_count": 71 + }, + { + "ta_code": "034", + "region_code": "08", + "population": 159, + "sa1_count": 1 + }, + { + "ta_code": "038", + "region_code": "06", + "population": 24, + "sa1_count": 1 + }, + { + "ta_code": "038", + "region_code": "08", + "population": 15660, + "sa1_count": 110 + }, + { + "ta_code": "041", + "region_code": "08", + "population": 18660, + "sa1_count": 123 + }, + { + "ta_code": "041", + "region_code": "09", + "population": 6, + "sa1_count": 1 + }, + { + "ta_code": "068", + "region_code": "13", + "population": 1896, + "sa1_count": 17 + }, + { + "ta_code": "068", + "region_code": "14", + "population": 21561, + "sa1_count": 143 + } + ], + "region_totals": [ + { + "region_code": "01", + "population": 193869, + "anchored_population": 193869, + "outside_ta_population": 0 + }, + { + "region_code": "02", + "population": 1656252, + "anchored_population": 1656252, + "outside_ta_population": 0 + }, + { + "region_code": "03", + "population": 498798, + "anchored_population": 498798, + "outside_ta_population": 0 + }, + { + "region_code": "04", + "population": 334161, + "anchored_population": 334128, + "outside_ta_population": 33 + }, + { + "region_code": "05", + "population": 51129, + "anchored_population": 51129, + "outside_ta_population": 0 + }, + { + "region_code": "06", + "population": 175044, + "anchored_population": 175044, + "outside_ta_population": 0 + }, + { + "region_code": "07", + "population": 125985, + "anchored_population": 125985, + "outside_ta_population": 0 + }, + { + "region_code": "08", + "population": 251511, + "anchored_population": 251511, + "outside_ta_population": 0 + }, + { + "region_code": "09", + "population": 520893, + "anchored_population": 520893, + "outside_ta_population": 0 + }, + { + "region_code": "12", + "population": 33351, + "anchored_population": 33351, + "outside_ta_population": 0 + }, + { + "region_code": "13", + "population": 650961, + "anchored_population": 650961, + "outside_ta_population": 0 + }, + { + "region_code": "14", + "population": 240885, + "anchored_population": 240885, + "outside_ta_population": 0 + }, + { + "region_code": "15", + "population": 100143, + "anchored_population": 100143, + "outside_ta_population": 0 + }, + { + "region_code": "16", + "population": 57858, + "anchored_population": 57858, + "outside_ta_population": 0 + }, + { + "region_code": "17", + "population": 52497, + "anchored_population": 52497, + "outside_ta_population": 0 + }, + { + "region_code": "18", + "population": 49365, + "anchored_population": 49365, + "outside_ta_population": 0 + }, + { + "region_code": "99", + "population": 612, + "anchored_population": 612, + "outside_ta_population": 0 + } + ], + "meshblock_count": 57575, + "concordance_sa1_count": 33170, + "concordance_sa1s_without_census": 353, + "source_provenance": { + "pages": [ + { + "file": "mbhg-2026-regc-p000.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=0&resultRecordCount=2000", + "sha256": "e1e984283d49f4dba3757144e40b699796bf1c2ea1a34fb524015b56ba8a0b70", + "bytes": 521003, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p001.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=2000&resultRecordCount=2000", + "sha256": "33ad698c6e732312900b6303fa57e82ec5ea0f220038d583ff40d694a5a42241", + "bytes": 514300, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p002.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=4000&resultRecordCount=2000", + "sha256": "59961bdc25052d9a343643735da35609d677faf26194c2fd147eabcbc0e52d01", + "bytes": 510843, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p003.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=6000&resultRecordCount=2000", + "sha256": "7ed90527fba6c68a523e6db150e4cb129978a35676f8201a26f12e4533303ec2", + "bytes": 507377, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p004.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=8000&resultRecordCount=2000", + "sha256": "b7f1e845c837124b1a07e54b2c8b815c225a00deacc75f237b944e5e7d064f39", + "bytes": 510956, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p005.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=10000&resultRecordCount=2000", + "sha256": "a6e6514c2ac7537ab2d0b0158c200de564167b1599f80d7a7d570070b542e9dd", + "bytes": 508691, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p006.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=12000&resultRecordCount=2000", + "sha256": "ce785717911faccfab894dd49e9c2f692e73d42cee62909a2cc779d9db06ed1c", + "bytes": 506340, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p007.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=14000&resultRecordCount=2000", + "sha256": "ebcdf665068b37447bcddb629bc4d2f9bdff099113eae506fd922089f5b20aa8", + "bytes": 535730, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p008.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=16000&resultRecordCount=2000", + "sha256": "ee2f315e8979e745d6ed5c4b0c99901839366a793b4d9abcc9fd68c5897199c0", + "bytes": 528114, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p009.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=18000&resultRecordCount=2000", + "sha256": "06ccf71f83243bbae575b8055a89e08333bc78a5a1e2f509dab4251a7e05b7cf", + "bytes": 518165, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p010.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=20000&resultRecordCount=2000", + "sha256": "2e54c88fa2c53a4131605adf1a25268df62de4c9587164e56c669187f0b45792", + "bytes": 530076, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p011.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=22000&resultRecordCount=2000", + "sha256": "685e71a8b26fe2d33da66cadb350ab6de65daca0a4397bcc5699e4730dab5bfb", + "bytes": 542506, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p012.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=24000&resultRecordCount=2000", + "sha256": "a0829709d98edea532a5b8fd19371734e7a374e01341edc232ed62102dd8163c", + "bytes": 535178, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p013.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=26000&resultRecordCount=2000", + "sha256": "41d4db88e39694cc4354209f1bfff710f07f0dcd86aeb6f2d2830a025f803d4e", + "bytes": 514352, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p014.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=28000&resultRecordCount=2000", + "sha256": "b577cce44704864fc6bba62e088f766af70f8f5fc0725c7d2ee2afda6fa968e2", + "bytes": 523320, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p015.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=30000&resultRecordCount=2000", + "sha256": "aa5d2575c93d841a6d2119cad8bb18b41c681d7c94766f547733608004be53ff", + "bytes": 513997, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p016.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=32000&resultRecordCount=2000", + "sha256": "a2841c24d03b085993c6537bbe3d741275cc85b7f4c637469e193c39bbfc970d", + "bytes": 522196, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p017.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=34000&resultRecordCount=2000", + "sha256": "1e96c882a4e0a62665b88258e580790fc270f96bd30fb24fdc3c1057a005b01c", + "bytes": 521764, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p018.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=36000&resultRecordCount=2000", + "sha256": "cc7521961e6c58b76fde38b0f9d733b2cc548320507a3190dd7dd8064ed2a3cd", + "bytes": 501252, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p019.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=38000&resultRecordCount=2000", + "sha256": "21a908f590b627511552269556877575ebc07739e8ffcf5193b35f84c57f9e82", + "bytes": 520360, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p020.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=40000&resultRecordCount=2000", + "sha256": "5fa0fb56d80928156336393b16c2ded43723b2451a3beaa0bebf4405c4966e95", + "bytes": 521326, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p021.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=42000&resultRecordCount=2000", + "sha256": "1687f3810ac3e6d102cfcfba46a4a9144783d9e25dd53f65bfe5181a054eb756", + "bytes": 514036, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p022.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=44000&resultRecordCount=2000", + "sha256": "c86bdd6358ca59ebbd649d999757421225f8e6765ed9c77dc2068dfac76d93fa", + "bytes": 518806, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p023.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=46000&resultRecordCount=2000", + "sha256": "05b77539c17a8372244c5d32f198e5fccd5627283056df86edebbc33422996aa", + "bytes": 520836, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p024.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=48000&resultRecordCount=2000", + "sha256": "1677d482d346196e854dddea8b392d64f6966b96178ecaaf784ac561f65102f2", + "bytes": 521491, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p025.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=50000&resultRecordCount=2000", + "sha256": "b84a06ee52108d764dbcf2f952bfbae3a7b8bd78ca715f87e5ae4ca88115e1e7", + "bytes": 520123, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p026.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=52000&resultRecordCount=2000", + "sha256": "e10e772428ed3a9dbbb2c5f855c56d64503eb00da5a8b4201a1ca148a43ab4b7", + "bytes": 517802, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p027.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=54000&resultRecordCount=2000", + "sha256": "ebe3c768a5caa52a56a3a3ad4c0b2a2e060aa1839aa5a4f88bbd8a4bc07bf57e", + "bytes": 518919, + "features": 2000 + }, + { + "file": "mbhg-2026-regc-p028.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=56000&resultRecordCount=2000", + "sha256": "a31cdd9e44109207e0e55e09ec515014e97b0b6dccb362578854e7eb57c0b05c", + "bytes": 409787, + "features": 1575 + } + ], + "layers": [] + } +} diff --git a/packages/microcosm-build/src/microcosm/build/nz/atomic_geography_support.json b/packages/microcosm-build/src/microcosm/build/nz/atomic_geography_support.json new file mode 100644 index 0000000000..d3e07dbc8b --- /dev/null +++ b/packages/microcosm-build/src/microcosm/build/nz/atomic_geography_support.json @@ -0,0 +1,1588 @@ +{ + "version": 1, + "level": "ta_region_as_area", + "code_system": "stats_nz_joint_ta_regc_as", + "vintage": "ta2026_regc2025_au2017", + "columns": { + "area": { + "kind": "code", + "source": "Stats NZ Meshblock Higher Geographies 2026; G8-m SA1 to AS placement", + "vintage": "ta2026_regc2025_au2017", + "relation": "exact" + }, + "ta_code": { + "kind": "code", + "source": "Stats NZ Meshblock Higher Geographies 2026", + "vintage": "ta_2026", + "relation": "official_tabulation" + }, + "region_code": { + "kind": "code", + "source": "Stats NZ Meshblock Higher Geographies 2026", + "vintage": "regc_2025", + "relation": "official_tabulation" + }, + "as_area": { + "kind": "code", + "source": "G8-m SA1 interior-point/centroid AU2017 bridge", + "vintage": "au_2017", + "relation": "best_fit" + }, + "population_code": { + "kind": "code", + "source": "Stats NZ TA ERP target hierarchy", + "vintage": "ta_2025", + "relation": "exact" + }, + "population": { + "kind": "weight", + "source": "Stats NZ TA ERP at 30 June 2025", + "basis": "TA ERP apportioned by within-TA 2023 Census SA1 usually resident population shares" + } + }, + "rows": [ + { + "target": "stats_nz_population_by_territorial_authority__ta001", + "codes": { + "area": "001|01|2", + "ta_code": "001", + "region_code": "01", + "as_area": "2", + "population_code": "nz-ta-001" + }, + "population_share": 0.11744924124595402 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta001", + "codes": { + "area": "001|01|3", + "ta_code": "001", + "region_code": "01", + "as_area": "3", + "population_code": "nz-ta-001" + }, + "population_share": 0.24364201942074068 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta001", + "codes": { + "area": "001|01|4", + "ta_code": "001", + "region_code": "01", + "as_area": "4", + "population_code": "nz-ta-001" + }, + "population_share": 0.6389087393333053 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta002", + "codes": { + "area": "002|01|2", + "ta_code": "002", + "region_code": "01", + "as_area": "2", + "population_code": "nz-ta-002" + }, + "population_share": 0.6245147666221545 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta002", + "codes": { + "area": "002|01|4", + "ta_code": "002", + "region_code": "01", + "as_area": "4", + "population_code": "nz-ta-002" + }, + "population_share": 0.3754852333778454 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta003", + "codes": { + "area": "003|01|2", + "ta_code": "003", + "region_code": "01", + "as_area": "2", + "population_code": "nz-ta-003" + }, + "population_share": 0.20433221359898066 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta003", + "codes": { + "area": "003|01|3", + "ta_code": "003", + "region_code": "01", + "as_area": "3", + "population_code": "nz-ta-003" + }, + "population_share": 0.19390710066025715 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta003", + "codes": { + "area": "003|01|4", + "ta_code": "003", + "region_code": "01", + "as_area": "4", + "population_code": "nz-ta-003" + }, + "population_share": 0.6017606857407622 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta011", + "codes": { + "area": "011|03|2", + "ta_code": "011", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-011" + }, + "population_share": 0.31483737932327305 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta011", + "codes": { + "area": "011|03|3", + "ta_code": "011", + "region_code": "03", + "as_area": "3", + "population_code": "nz-ta-011" + }, + "population_share": 0.32533508295060454 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta011", + "codes": { + "area": "011|03|4", + "ta_code": "011", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-011" + }, + "population_share": 0.3598275377261224 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta012", + "codes": { + "area": "012|03|2", + "ta_code": "012", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-012" + }, + "population_share": 0.054350887074063645 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta012", + "codes": { + "area": "012|03|3", + "ta_code": "012", + "region_code": "03", + "as_area": "3", + "population_code": "nz-ta-012" + }, + "population_share": 0.5385806814981695 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta012", + "codes": { + "area": "012|03|4", + "ta_code": "012", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-012" + }, + "population_share": 0.40706843142776683 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta013", + "codes": { + "area": "013|03|1", + "ta_code": "013", + "region_code": "03", + "as_area": "1", + "population_code": "nz-ta-013" + }, + "population_share": 0.16983173916079033 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta013", + "codes": { + "area": "013|03|2", + "ta_code": "013", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-013" + }, + "population_share": 0.5660825246107659 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta013", + "codes": { + "area": "013|03|3", + "ta_code": "013", + "region_code": "03", + "as_area": "3", + "population_code": "nz-ta-013" + }, + "population_share": 0.09578998813097815 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta013", + "codes": { + "area": "013|03|4", + "ta_code": "013", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-013" + }, + "population_share": 0.16829574809746561 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta015", + "codes": { + "area": "015|03|2", + "ta_code": "015", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-015" + }, + "population_share": 0.2387878787878788 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta015", + "codes": { + "area": "015|03|3", + "ta_code": "015", + "region_code": "03", + "as_area": "3", + "population_code": "nz-ta-015" + }, + "population_share": 0.34715151515151516 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta015", + "codes": { + "area": "015|03|4", + "ta_code": "015", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-015" + }, + "population_share": 0.4140606060606061 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta016", + "codes": { + "area": "016|03|2", + "ta_code": "016", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-016" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta017", + "codes": { + "area": "017|03|2", + "ta_code": "017", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-017" + }, + "population_share": 0.8063081484510787 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta017", + "codes": { + "area": "017|03|4", + "ta_code": "017", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-017" + }, + "population_share": 0.19369185154892138 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta018", + "codes": { + "area": "018|03|3", + "ta_code": "018", + "region_code": "03", + "as_area": "3", + "population_code": "nz-ta-018" + }, + "population_share": 0.2672811059907834 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta018", + "codes": { + "area": "018|03|4", + "ta_code": "018", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-018" + }, + "population_share": 0.7327188940092166 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta019", + "codes": { + "area": "019|03|4", + "ta_code": "019", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-019" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta020", + "codes": { + "area": "020|03|4", + "ta_code": "020", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-020" + }, + "population_share": 0.995302223614156 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta020", + "codes": { + "area": "020|08|4", + "ta_code": "020", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-020" + }, + "population_share": 0.004697776385844034 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta021", + "codes": { + "area": "021|03|2", + "ta_code": "021", + "region_code": "03", + "as_area": "2", + "population_code": "nz-ta-021" + }, + "population_share": 0.6471157424637142 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta021", + "codes": { + "area": "021|03|4", + "ta_code": "021", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-021" + }, + "population_share": 0.34774841831038333 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta021", + "codes": { + "area": "021|04|4", + "ta_code": "021", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-021" + }, + "population_share": 0.0030517305545217713 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta021", + "codes": { + "area": "021|06|4", + "ta_code": "021", + "region_code": "06", + "as_area": "4", + "population_code": "nz-ta-021" + }, + "population_share": 0.002084108671380722 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta021", + "codes": { + "area": "021|08|4", + "ta_code": "021", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-021" + }, + "population_share": 0.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta022", + "codes": { + "area": "022|04|1", + "ta_code": "022", + "region_code": "04", + "as_area": "1", + "population_code": "nz-ta-022" + }, + "population_share": 0.16740487752814984 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta022", + "codes": { + "area": "022|04|2", + "ta_code": "022", + "region_code": "04", + "as_area": "2", + "population_code": "nz-ta-022" + }, + "population_share": 0.29894871658039385 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta022", + "codes": { + "area": "022|04|4", + "ta_code": "022", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-022" + }, + "population_share": 0.5336464058914563 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta023", + "codes": { + "area": "023|04|1", + "ta_code": "023", + "region_code": "04", + "as_area": "1", + "population_code": "nz-ta-023" + }, + "population_share": 0.997977775160011 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta023", + "codes": { + "area": "023|04|4", + "ta_code": "023", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-023" + }, + "population_share": 0.0020222248399890054 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta024", + "codes": { + "area": "024|03|4", + "ta_code": "024", + "region_code": "03", + "as_area": "4", + "population_code": "nz-ta-024" + }, + "population_share": 0.05248876108703576 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta024", + "codes": { + "area": "024|04|3", + "ta_code": "024", + "region_code": "04", + "as_area": "3", + "population_code": "nz-ta-024" + }, + "population_share": 0.8148313150540683 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta024", + "codes": { + "area": "024|04|4", + "ta_code": "024", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-024" + }, + "population_share": 0.13267992385889596 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta025", + "codes": { + "area": "025|04|3", + "ta_code": "025", + "region_code": "04", + "as_area": "3", + "population_code": "nz-ta-025" + }, + "population_share": 0.5886816824089771 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta025", + "codes": { + "area": "025|04|4", + "ta_code": "025", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-025" + }, + "population_share": 0.41131831759102283 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta026", + "codes": { + "area": "026|04|4", + "ta_code": "026", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-026" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta027", + "codes": { + "area": "027|04|4", + "ta_code": "027", + "region_code": "04", + "as_area": "4", + "population_code": "nz-ta-027" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta028", + "codes": { + "area": "028|05|3", + "ta_code": "028", + "region_code": "05", + "as_area": "3", + "population_code": "nz-ta-028" + }, + "population_share": 0.7519216100451799 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta028", + "codes": { + "area": "028|05|4", + "ta_code": "028", + "region_code": "05", + "as_area": "4", + "population_code": "nz-ta-028" + }, + "population_share": 0.24807838995482015 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta029", + "codes": { + "area": "029|06|4", + "ta_code": "029", + "region_code": "06", + "as_area": "4", + "population_code": "nz-ta-029" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta030", + "codes": { + "area": "030|06|2", + "ta_code": "030", + "region_code": "06", + "as_area": "2", + "population_code": "nz-ta-030" + }, + "population_share": 0.8852247347850363 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta030", + "codes": { + "area": "030|06|4", + "ta_code": "030", + "region_code": "06", + "as_area": "4", + "population_code": "nz-ta-030" + }, + "population_share": 0.1147752652149637 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta031", + "codes": { + "area": "031|06|2", + "ta_code": "031", + "region_code": "06", + "as_area": "2", + "population_code": "nz-ta-031" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta032", + "codes": { + "area": "032|06|3", + "ta_code": "032", + "region_code": "06", + "as_area": "3", + "population_code": "nz-ta-032" + }, + "population_share": 0.1506875847375557 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta032", + "codes": { + "area": "032|06|4", + "ta_code": "032", + "region_code": "06", + "as_area": "4", + "population_code": "nz-ta-032" + }, + "population_share": 0.8493124152624443 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta033", + "codes": { + "area": "033|07|2", + "ta_code": "033", + "region_code": "07", + "as_area": "2", + "population_code": "nz-ta-033" + }, + "population_share": 0.7049123775355319 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta033", + "codes": { + "area": "033|07|3", + "ta_code": "033", + "region_code": "07", + "as_area": "3", + "population_code": "nz-ta-033" + }, + "population_share": 0.12391334345246309 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta033", + "codes": { + "area": "033|07|4", + "ta_code": "033", + "region_code": "07", + "as_area": "4", + "population_code": "nz-ta-033" + }, + "population_share": 0.17117427901200497 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta034", + "codes": { + "area": "034|07|4", + "ta_code": "034", + "region_code": "07", + "as_area": "4", + "population_code": "nz-ta-034" + }, + "population_share": 0.9843195266272189 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta034", + "codes": { + "area": "034|08|4", + "ta_code": "034", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-034" + }, + "population_share": 0.015680473372781067 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta035", + "codes": { + "area": "035|07|3", + "ta_code": "035", + "region_code": "07", + "as_area": "3", + "population_code": "nz-ta-035" + }, + "population_share": 0.44359504132231403 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta035", + "codes": { + "area": "035|07|4", + "ta_code": "035", + "region_code": "07", + "as_area": "4", + "population_code": "nz-ta-035" + }, + "population_share": 0.5564049586776859 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta036", + "codes": { + "area": "036|08|4", + "ta_code": "036", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-036" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta037", + "codes": { + "area": "037|08|4", + "ta_code": "037", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-037" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta038", + "codes": { + "area": "038|06|4", + "ta_code": "038", + "region_code": "06", + "as_area": "4", + "population_code": "nz-ta-038" + }, + "population_share": 0.001530221882172915 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta038", + "codes": { + "area": "038|08|4", + "ta_code": "038", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-038" + }, + "population_share": 0.9984697781178271 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta039", + "codes": { + "area": "039|08|3", + "ta_code": "039", + "region_code": "08", + "as_area": "3", + "population_code": "nz-ta-039" + }, + "population_share": 0.6989824236817761 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta039", + "codes": { + "area": "039|08|4", + "ta_code": "039", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-039" + }, + "population_share": 0.30101757631822385 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta040", + "codes": { + "area": "040|08|3", + "ta_code": "040", + "region_code": "08", + "as_area": "3", + "population_code": "nz-ta-040" + }, + "population_share": 0.9638516886425449 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta040", + "codes": { + "area": "040|08|4", + "ta_code": "040", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-040" + }, + "population_share": 0.03614831135745516 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta041", + "codes": { + "area": "041|08|4", + "ta_code": "041", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-041" + }, + "population_share": 0.9996785599485696 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta041", + "codes": { + "area": "041|09|4", + "ta_code": "041", + "region_code": "09", + "as_area": "4", + "population_code": "nz-ta-041" + }, + "population_share": 0.0003214400514304082 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta042", + "codes": { + "area": "042|08|3", + "ta_code": "042", + "region_code": "08", + "as_area": "3", + "population_code": "nz-ta-042" + }, + "population_share": 0.7093583980384144 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta042", + "codes": { + "area": "042|08|4", + "ta_code": "042", + "region_code": "08", + "as_area": "4", + "population_code": "nz-ta-042" + }, + "population_share": 0.2906416019615856 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta043", + "codes": { + "area": "043|09|2", + "ta_code": "043", + "region_code": "09", + "as_area": "2", + "population_code": "nz-ta-043" + }, + "population_share": 0.787906427728297 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta043", + "codes": { + "area": "043|09|3", + "ta_code": "043", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-043" + }, + "population_share": 0.14781628930142718 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta043", + "codes": { + "area": "043|09|4", + "ta_code": "043", + "region_code": "09", + "as_area": "4", + "population_code": "nz-ta-043" + }, + "population_share": 0.06427728297027578 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta044", + "codes": { + "area": "044|09|2", + "ta_code": "044", + "region_code": "09", + "as_area": "2", + "population_code": "nz-ta-044" + }, + "population_share": 0.9965660034339966 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta044", + "codes": { + "area": "044|09|3", + "ta_code": "044", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-044" + }, + "population_share": 0.003433996566003434 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta045", + "codes": { + "area": "045|09|2", + "ta_code": "045", + "region_code": "09", + "as_area": "2", + "population_code": "nz-ta-045" + }, + "population_share": 0.9447977447059595 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta045", + "codes": { + "area": "045|09|3", + "ta_code": "045", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-045" + }, + "population_share": 0.05520225529404052 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta046", + "codes": { + "area": "046|09|2", + "ta_code": "046", + "region_code": "09", + "as_area": "2", + "population_code": "nz-ta-046" + }, + "population_share": 0.9936126296998773 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta046", + "codes": { + "area": "046|09|3", + "ta_code": "046", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-046" + }, + "population_share": 0.006387370300122727 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta047", + "codes": { + "area": "047|09|2", + "ta_code": "047", + "region_code": "09", + "as_area": "2", + "population_code": "nz-ta-047" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta048", + "codes": { + "area": "048|09|3", + "ta_code": "048", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-048" + }, + "population_share": 0.8647945354006289 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta048", + "codes": { + "area": "048|09|4", + "ta_code": "048", + "region_code": "09", + "as_area": "4", + "population_code": "nz-ta-048" + }, + "population_share": 0.13520546459937113 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta049", + "codes": { + "area": "049|09|3", + "ta_code": "049", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-049" + }, + "population_share": 0.5669828097213989 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta049", + "codes": { + "area": "049|09|4", + "ta_code": "049", + "region_code": "09", + "as_area": "4", + "population_code": "nz-ta-049" + }, + "population_share": 0.4330171902786011 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta050", + "codes": { + "area": "050|09|3", + "ta_code": "050", + "region_code": "09", + "as_area": "3", + "population_code": "nz-ta-050" + }, + "population_share": 0.37986270022883295 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta050", + "codes": { + "area": "050|09|4", + "ta_code": "050", + "region_code": "09", + "as_area": "4", + "population_code": "nz-ta-050" + }, + "population_share": 0.620137299771167 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta051", + "codes": { + "area": "051|16|2", + "ta_code": "051", + "region_code": "16", + "as_area": "2", + "population_code": "nz-ta-051" + }, + "population_share": 0.6058280618064917 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta051", + "codes": { + "area": "051|16|3", + "ta_code": "051", + "region_code": "16", + "as_area": "3", + "population_code": "nz-ta-051" + }, + "population_share": 0.02400705174738152 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta051", + "codes": { + "area": "051|16|4", + "ta_code": "051", + "region_code": "16", + "as_area": "4", + "population_code": "nz-ta-051" + }, + "population_share": 0.3701648864461267 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta052", + "codes": { + "area": "052|17|2", + "ta_code": "052", + "region_code": "17", + "as_area": "2", + "population_code": "nz-ta-052" + }, + "population_share": 0.9757700440025144 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta052", + "codes": { + "area": "052|17|4", + "ta_code": "052", + "region_code": "17", + "as_area": "4", + "population_code": "nz-ta-052" + }, + "population_share": 0.02422995599748557 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta053", + "codes": { + "area": "053|18|2", + "ta_code": "053", + "region_code": "18", + "as_area": "2", + "population_code": "nz-ta-053" + }, + "population_share": 0.6970525676086295 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta053", + "codes": { + "area": "053|18|3", + "ta_code": "053", + "region_code": "18", + "as_area": "3", + "population_code": "nz-ta-053" + }, + "population_share": 0.0956548161652993 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta053", + "codes": { + "area": "053|18|4", + "ta_code": "053", + "region_code": "18", + "as_area": "4", + "population_code": "nz-ta-053" + }, + "population_share": 0.2072926162260711 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta054", + "codes": { + "area": "054|13|3", + "ta_code": "054", + "region_code": "13", + "as_area": "3", + "population_code": "nz-ta-054" + }, + "population_share": 0.5217081850533808 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta054", + "codes": { + "area": "054|13|4", + "ta_code": "054", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-054" + }, + "population_share": 0.4782918149466192 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta055", + "codes": { + "area": "055|12|4", + "ta_code": "055", + "region_code": "12", + "as_area": "4", + "population_code": "nz-ta-055" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta056", + "codes": { + "area": "056|12|3", + "ta_code": "056", + "region_code": "12", + "as_area": "3", + "population_code": "nz-ta-056" + }, + "population_share": 0.6768671089236037 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta056", + "codes": { + "area": "056|12|4", + "ta_code": "056", + "region_code": "12", + "as_area": "4", + "population_code": "nz-ta-056" + }, + "population_share": 0.3231328910763963 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta057", + "codes": { + "area": "057|12|3", + "ta_code": "057", + "region_code": "12", + "as_area": "3", + "population_code": "nz-ta-057" + }, + "population_share": 0.39979757085020245 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta057", + "codes": { + "area": "057|12|4", + "ta_code": "057", + "region_code": "12", + "as_area": "4", + "population_code": "nz-ta-057" + }, + "population_share": 0.6002024291497976 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta058", + "codes": { + "area": "058|13|2", + "ta_code": "058", + "region_code": "13", + "as_area": "2", + "population_code": "nz-ta-058" + }, + "population_share": 0.1786660777385159 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta058", + "codes": { + "area": "058|13|3", + "ta_code": "058", + "region_code": "13", + "as_area": "3", + "population_code": "nz-ta-058" + }, + "population_share": 0.0706713780918728 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta058", + "codes": { + "area": "058|13|4", + "ta_code": "058", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-058" + }, + "population_share": 0.7506625441696113 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta059", + "codes": { + "area": "059|13|2", + "ta_code": "059", + "region_code": "13", + "as_area": "2", + "population_code": "nz-ta-059" + }, + "population_share": 0.5989854612980661 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta059", + "codes": { + "area": "059|13|4", + "ta_code": "059", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-059" + }, + "population_share": 0.401014538701934 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta060", + "codes": { + "area": "060|13|2", + "ta_code": "060", + "region_code": "13", + "as_area": "2", + "population_code": "nz-ta-060" + }, + "population_share": 0.9915452364344354 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta060", + "codes": { + "area": "060|13|4", + "ta_code": "060", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-060" + }, + "population_share": 0.00845476356556466 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta062", + "codes": { + "area": "062|13|2", + "ta_code": "062", + "region_code": "13", + "as_area": "2", + "population_code": "nz-ta-062" + }, + "population_share": 0.6331554087784648 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta062", + "codes": { + "area": "062|13|4", + "ta_code": "062", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-062" + }, + "population_share": 0.3668445912215353 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta063", + "codes": { + "area": "063|13|2", + "ta_code": "063", + "region_code": "13", + "as_area": "2", + "population_code": "nz-ta-063" + }, + "population_share": 0.6249352443446727 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta063", + "codes": { + "area": "063|13|3", + "ta_code": "063", + "region_code": "13", + "as_area": "3", + "population_code": "nz-ta-063" + }, + "population_share": 0.045933344845449836 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta063", + "codes": { + "area": "063|13|4", + "ta_code": "063", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-063" + }, + "population_share": 0.3291314108098774 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta064", + "codes": { + "area": "064|13|3", + "ta_code": "064", + "region_code": "13", + "as_area": "3", + "population_code": "nz-ta-064" + }, + "population_share": 0.7654554630330558 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta064", + "codes": { + "area": "064|13|4", + "ta_code": "064", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-064" + }, + "population_share": 0.23454453696694424 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta065", + "codes": { + "area": "065|13|3", + "ta_code": "065", + "region_code": "13", + "as_area": "3", + "population_code": "nz-ta-065" + }, + "population_share": 0.29115407147041594 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta065", + "codes": { + "area": "065|13|4", + "ta_code": "065", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-065" + }, + "population_share": 0.7088459285295841 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta066", + "codes": { + "area": "066|13|4", + "ta_code": "066", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-066" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta067", + "codes": { + "area": "067|99|4", + "ta_code": "067", + "region_code": "99", + "as_area": "4", + "population_code": "nz-ta-067" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta068", + "codes": { + "area": "068|13|4", + "ta_code": "068", + "region_code": "13", + "as_area": "4", + "population_code": "nz-ta-068" + }, + "population_share": 0.08082875047960097 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta068", + "codes": { + "area": "068|14|3", + "ta_code": "068", + "region_code": "14", + "as_area": "3", + "population_code": "nz-ta-068" + }, + "population_share": 0.6140171377413992 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta068", + "codes": { + "area": "068|14|4", + "ta_code": "068", + "region_code": "14", + "as_area": "4", + "population_code": "nz-ta-068" + }, + "population_share": 0.30515411177899987 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta069", + "codes": { + "area": "069|14|2", + "ta_code": "069", + "region_code": "14", + "as_area": "2", + "population_code": "nz-ta-069" + }, + "population_share": 0.2607032695866749 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta069", + "codes": { + "area": "069|14|3", + "ta_code": "069", + "region_code": "14", + "as_area": "3", + "population_code": "nz-ta-069" + }, + "population_share": 0.23022825416409623 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta069", + "codes": { + "area": "069|14|4", + "ta_code": "069", + "region_code": "14", + "as_area": "4", + "population_code": "nz-ta-069" + }, + "population_share": 0.5090684762492289 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta070", + "codes": { + "area": "070|14|1", + "ta_code": "070", + "region_code": "14", + "as_area": "1", + "population_code": "nz-ta-070" + }, + "population_share": 0.5776035131744041 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta070", + "codes": { + "area": "070|14|4", + "ta_code": "070", + "region_code": "14", + "as_area": "4", + "population_code": "nz-ta-070" + }, + "population_share": 0.422396486825596 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta071", + "codes": { + "area": "071|14|3", + "ta_code": "071", + "region_code": "14", + "as_area": "3", + "population_code": "nz-ta-071" + }, + "population_share": 0.9364698761523419 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta071", + "codes": { + "area": "071|14|4", + "ta_code": "071", + "region_code": "14", + "as_area": "4", + "population_code": "nz-ta-071" + }, + "population_share": 0.06353012384765806 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta072", + "codes": { + "area": "072|14|4", + "ta_code": "072", + "region_code": "14", + "as_area": "4", + "population_code": "nz-ta-072" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta073", + "codes": { + "area": "073|15|3", + "ta_code": "073", + "region_code": "15", + "as_area": "3", + "population_code": "nz-ta-073" + }, + "population_share": 0.07764062941675304 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta073", + "codes": { + "area": "073|15|4", + "ta_code": "073", + "region_code": "15", + "as_area": "4", + "population_code": "nz-ta-073" + }, + "population_share": 0.9223593705832469 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta074", + "codes": { + "area": "074|15|4", + "ta_code": "074", + "region_code": "15", + "as_area": "4", + "population_code": "nz-ta-074" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta075", + "codes": { + "area": "075|15|4", + "ta_code": "075", + "region_code": "15", + "as_area": "4", + "population_code": "nz-ta-075" + }, + "population_share": 1.0 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta076", + "codes": { + "area": "076|02|1", + "ta_code": "076", + "region_code": "02", + "as_area": "1", + "population_code": "nz-ta-076" + }, + "population_share": 0.9837162460784953 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta076", + "codes": { + "area": "076|02|2", + "ta_code": "076", + "region_code": "02", + "as_area": "2", + "population_code": "nz-ta-076" + }, + "population_share": 0.015863528013852966 + }, + { + "target": "stats_nz_population_by_territorial_authority__ta076", + "codes": { + "area": "076|02|4", + "ta_code": "076", + "region_code": "02", + "as_area": "4", + "population_code": "nz-ta-076" + }, + "population_share": 0.00042022590765173414 + } + ], + "share_tolerance": 1e-12, + "population_geography_level": "local_authority", + "population_code_column": "population_code" +} diff --git a/packages/microcosm-build/src/microcosm/build/nz/country_package.json b/packages/microcosm-build/src/microcosm/build/nz/country_package.json index 9f0e7c2a6b..d7ab8405cb 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/country_package.json +++ b/packages/microcosm-build/src/microcosm/build/nz/country_package.json @@ -42,6 +42,11 @@ "kind": "legacy_json", "schema_id": "legacy_json" }, + { + "path": "atomic_geography_support.json", + "kind": "legacy_json", + "schema_id": "legacy_json" + }, { "path": "axiom_input_closure.json", "kind": "legacy_json", diff --git a/packages/microcosm-build/src/microcosm/build/nz/geography_spine.json b/packages/microcosm-build/src/microcosm/build/nz/geography_spine.json index ca44bec433..00822510f4 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/geography_spine.json +++ b/packages/microcosm-build/src/microcosm/build/nz/geography_spine.json @@ -1,7 +1,7 @@ { "version": 1, "country": "nz", - "policy": "One national New Zealand dataset carries Stats NZ region codes for calibration and filtering. Region is target-assigned on US donor support records, never represented as observed donor geography. In the graph build each household draws one atomic unit (territorial authority intersected with Accommodation Supplement area) from population-weighted support built from Chronicle territorial-authority population facts and as_area_crosswalk.json; region, territorial authority and Accommodation Supplement area derive from that unit. Finer layers remain columns on this same national dataset, not separate files.", + "policy": "One national New Zealand dataset carries Stats NZ region codes for calibration and filtering. Region is target-assigned on US donor support records, never represented as observed donor geography. In the graph build each household draws one joint atomic unit (territorial authority intersected with region and Accommodation Supplement area) from atomic_geography_support.json; region, territorial authority and Accommodation Supplement area derive from that unit. Joint SA1 Census population shares split each published territorial-authority ERP anchor across its region and AS cells, conserving TA ERP exactly; regional ERP sums are approximate diagnostics. Finer layers remain columns on this same national dataset, not separate files.", "geography_spine": { "stage": "assign_nz_regions", "method": "clone_assign_uniform", @@ -16,8 +16,8 @@ "assignment_source": { "survey": "Stats NZ subnational population estimates at 30 June 2025", "source": "https://www.stats.govt.nz/information-releases/subnational-population-estimates-at-30-june-2025/", - "notes": "Region follows from each household's atomic territorial-authority by Accommodation Supplement area draw, whose support weights come from Stats NZ population facts, and is broadcast to family and person tables; the age-by-region, all sexes cells are calibration targets. The pinned Chronicle feed supplies all-sex age-by-region cells for the 16 ERP regions and all-age ERP for 67 territorial authorities. Region 99 is retained separately under a national-growth proxy; assigning its geography support remains an explicit prerequisite." + "notes": "The generated atomic_geography_support.json definition uses the official Meshblock Higher Geographies 2026 SA1-to-TA-and-REGC concordance and the existing as_area_crosswalk.json AU2017 placement rule. The pinned Chronicle feed supplies all-age ERP for 67 real territorial authorities. Largest-remainder apportionment preserves each TA ERP total; the all-sex age-by-region cells remain calibration targets. Region 99 has separate cells from its own SA1s under TA 067. TA 999 has no ERP anchor: its 33 Census residents remain audit-only outside-TA cells in the generator report, without sampling mass or redistribution." }, - "notes": "One clone per record is the compile-safe national starting point. This generation-0 record describes the region layer only; the shared graph geography kernels execute assignment. The exact 16-region ERP roster, pinned feed identity and harvested territorial-authority to Accommodation Supplement area shares are declared. Reviewed assignment support for region 99 remains required; it is not TA 999." + "notes": "One clone per record is the compile-safe national starting point. This generation-0 record describes the region layer; the shared graph geography kernels can assign one joint atomic area and look up all layers. The generated support is spec data only: NZ transport graph activation remains G8-w3 work. Whole-SA1 AU2017 allocation retains the existing interior-point/centroid approximation; region is never inferred from TA alone." } } diff --git a/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml index 2778934566..48d2a4497e 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml @@ -10,11 +10,11 @@ sources: value: '2024' vintages: - vintage:nz_support_pool_2024_buildp -- byte_size: 2207 +- byte_size: 2448 id: nz_region_assignment_contract loader: kernel:assign_nz_regions role: nz_region_assignment_contract - sha256: 799bb85e0e4ef943b9f14c6223e2b6168d587e09d1fbf8c7ea2e1aaa0eaee17d + sha256: 5f2b1bdd9f8768249912ffd0fbcb2f7d4ed493b51c74306f793ec12441fd383f vintage_authorities: - id: nz_region_2025 kind: geography_vintage diff --git a/packages/microcosm-build/tests/engine_free/shared/test_fetch_nz_as_area_sources.py b/packages/microcosm-build/tests/engine_free/shared/test_fetch_nz_as_area_sources.py index 8b6168ad1f..3ebfba56b1 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_fetch_nz_as_area_sources.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_fetch_nz_as_area_sources.py @@ -5,11 +5,13 @@ import hashlib import importlib.util import json -from pathlib import Path +from urllib.parse import parse_qs, urlsplit import pytest -REPO = Path(__file__).resolve().parents[5] +from test_support.paths import paths_for + +REPO = paths_for("microcosm-build").repository SPEC = REPO / "packages/microcosm-build/src/microcosm/build/nz/as_area_crosswalk.json" _loader = importlib.util.spec_from_file_location( "fetch_nz_as_area_sources", REPO / "tools/fetch_nz_as_area_sources.py" @@ -80,3 +82,84 @@ def fetch(url): assert fetched == ["b.json"] assert calls == ["https://example.test/b.json"] assert (tmp_path / "b.json").read_bytes() == b"beta" + + +def test_joint_geography_pages_pin_the_complete_regc_concordance(): + provenance = fetcher.JOINT_GEOGRAPHY_PROVENANCE + downloads = fetcher.pinned_downloads(provenance) + assert len(downloads) == 29 + assert provenance["layers"] == [] + assert sum(page["features"] for page in provenance["pages"]) == 57575 + for index, (name, url, sha256, size) in enumerate(downloads): + assert name == f"mbhg-2026-regc-p{index:03d}.json" + parsed = urlsplit(url) + assert parsed.scheme == "https" + assert parsed.netloc == "services2.arcgis.com" + assert parsed.path.endswith( + "/Meshblock_Higher_Geographies_2026/FeatureServer/0/query" + ) + query = parse_qs(parsed.query) + assert query["resultOffset"] == [str(index * 2000)] + assert query["resultRecordCount"] == ["2000"] + assert set(query["outFields"][0].split(",")) == { + "MB2026_V1_00", + "SA12026_V1_00", + "TA2026_V1_00", + "TA2026_V1_00_NAME", + "REGC2025_V1_00", + "REGC2025_V1_00_NAME", + "TALB2026_V1_00", + "TALB2026_V1_00_NAME", + } + assert len(sha256) == 64 + assert set(sha256) <= set("0123456789abcdef") + assert size > 0 + + +def test_joint_geography_refuses_unpinned_page(tmp_path): + provenance = fetcher.JOINT_GEOGRAPHY_PROVENANCE + first_page = provenance["pages"][0] + with pytest.raises(ValueError, match="SHA-256"): + fetcher.fetch_all( + provenance, tmp_path, fetch=lambda _url: b"\0" * first_page["bytes"] + ) + assert not (tmp_path / first_page["file"]).exists() + + +@pytest.mark.parametrize("joint_geography", [False, True]) +def test_cli_uses_selected_provenance_and_source_environment( + tmp_path, monkeypatch, joint_geography +): + monkeypatch.setenv("NZ_AS_AREA_SOURCES", str(tmp_path / "as")) + monkeypatch.setenv("NZ_JOINT_GEOGRAPHY_SOURCES", str(tmp_path / "joint")) + captured = [] + + def fetch_all(provenance, out_dir): + captured.append((provenance, out_dir)) + return [] + + monkeypatch.setattr(fetcher, "fetch_all", fetch_all) + args = ["--joint-geography"] if joint_geography else ["--spec", str(SPEC)] + assert fetcher.main(args) == 0 + provenance, out_dir = captured[0] + if joint_geography: + assert provenance is fetcher.JOINT_GEOGRAPHY_PROVENANCE + assert out_dir == tmp_path / "joint" + else: + assert provenance == json.loads(SPEC.read_text())["provenance"] + assert out_dir == tmp_path / "as" + + +def test_cli_explicit_output_overrides_joint_geography_environment( + tmp_path, monkeypatch +): + monkeypatch.setenv("NZ_JOINT_GEOGRAPHY_SOURCES", str(tmp_path / "unused")) + captured = [] + + def fetch_all(_provenance, out_dir): + captured.append(out_dir) + return [] + + monkeypatch.setattr(fetcher, "fetch_all", fetch_all) + assert fetcher.main(["--joint-geography", "--out", str(tmp_path)]) == 0 + assert captured == [tmp_path] diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_as_area_crosswalk.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_as_area_crosswalk.py index 042a5edcd6..aa69bed68e 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_as_area_crosswalk.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_as_area_crosswalk.py @@ -16,7 +16,7 @@ import numpy as np import pytest -from hypothesis import given, settings +from hypothesis import HealthCheck, given, settings from hypothesis import strategies as st from test_support.paths import paths_for @@ -655,7 +655,13 @@ def test_unexpected_zero_population_authority_refuses() -> None: ) -@settings(max_examples=40, deadline=None) +# Four-item draws can be descheduled on a busy shared host; test correctness, +# independently of Hypothesis's wall-clock input-generation health check. +@settings( + max_examples=40, + deadline=None, + suppress_health_check=[HealthCheck.too_slow], +) @given( populations=st.lists(st.integers(1, 20), min_size=4, max_size=4), order=st.permutations((0, 1, 2, 3)), diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_joint_geography.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_joint_geography.py new file mode 100644 index 0000000000..4edbf32a8a --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_joint_geography.py @@ -0,0 +1,686 @@ +"""Joint SA1 geography, executable support, and independently checked source mass. + +The staged-source replay is optional. Small correlated cells exercise the same +generator without public ArcGIS bytes, including the independence mutant. +""" + +from __future__ import annotations + +import copy +import hashlib +import json +import math +import os +from collections import Counter, defaultdict +from fractions import Fraction +from pathlib import Path + +import numpy as np +import pandas as pd +import pytest +from hypothesis import given, settings +from hypothesis import strategies as st + +from microcosm.build import atomic_geography as geography +from microcosm.build.country_spec import load_country_spec +from microcosm.build.ledger_artifact import load_ledger_consumer_artifact +from microcosm.build.ledger_targets import ( + LedgerTargetReference, + compile_ledger_target_references, +) +from microcosm.build.transport.geography_kernels import support_from_surface +from microcosm.build.transport.target_kernels import ( + TargetSurface, + decode_target_surface, + encode_target_surface, +) +from microcosm.calibrate import TargetRegistry, TargetSpec +from microcosm.calibrate.hierarchy import ( + CalibrationHierarchy, + HierarchyCategory, + HierarchyGeography, + HierarchyNode, +) +from test_support.paths import paths_for +from tools import build_nz_joint_geography as builder + +_PATHS = paths_for("microcosm-build") +_SPEC = _PATHS.package / "src/microcosm/build/nz" +_STRADDLING = { + "020": {"03", "08"}, + "021": {"03", "04", "06", "08"}, + "024": {"03", "04"}, + "034": {"07", "08"}, + "038": {"06", "08"}, + "041": {"08", "09"}, + "068": {"13", "14"}, +} + + +def _read(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def _definition() -> dict: + return _read(_SPEC / "atomic_geography_support.json") + + +def _references(codes: set[str] | None = None) -> list[dict]: + rows = _read(_SPEC / "precal_references.json")["target_references"] + return [ + row + for row in rows + if row["metadata"].get("precal_use") == "atomic_geography_support" + and (codes is None or row["ledger_selector"]["geography_id"][-3:] in codes) + ] + + +def _surface(references: list[dict], populations: list[int]) -> TargetSurface: + """Use the real reference names and hierarchy ids with declared fixture counts.""" + specs = [] + for reference, population in zip(references, populations, strict=True): + selector = reference["ledger_selector"] + specs.append( + TargetSpec( + name=reference["name"], + entity="person", + value=population, + measure="people", + period=2025, + source="Synthetic counts for NZ support contract verification", + metadata={ + "precal_use": "atomic_geography_support", + "ledger_measure_unit": "count", + }, + hierarchy=CalibrationHierarchy( + provider=HierarchyNode("stats_nz", "Stats NZ"), + category=HierarchyCategory("demography", "Demography", "stats_nz"), + geography=HierarchyGeography( + selector["geography_id"], + selector["geography_id"], + selector["geography_level"], + ), + dimensions=(), + target=HierarchyNode(reference["name"], reference["name"]), + ), + ) + ) + return TargetSurface( + country="nz", + registry=TargetRegistry(specs, country="nz"), + trace=(), + references_sha256="1" * 64, + facts={"facts_sha256": "2" * 64}, + sha256="3" * 64, + ) + + +def _fixture() -> tuple[list[dict], dict, list[dict]]: + placements, concordance = [], {} + for index, (ta, region, area, population) in enumerate( + [ + ("020", "03", 1, 9), + ("020", "03", 4, 1), + ("020", "08", 1, 1), + ("020", "08", 4, 9), + ("067", "99", 4, 612), + ("999", "04", 4, 33), + ] + ): + sa1 = f"fixture-{index}" + placements.append( + {"sa1_code": sa1, "ta_code": ta, "as_area": area, "population": population} + ) + concordance[sa1] = {"ta_code": ta, "region_code": region} + return placements, concordance, _references({"020", "067"}) + + +def _expected(placements: list[dict], concordance: dict) -> Counter: + cells = Counter() + for placement in placements: + joint = concordance[placement["sa1_code"]] + assert joint["ta_code"] == placement["ta_code"] + cells[(joint["ta_code"], joint["region_code"], placement["as_area"])] += ( + placement["population"] + ) + return cells + + +def _assert_support_matches_cells(definition: dict, cells: Counter) -> None: + totals = Counter() + for (ta, _, _), population in cells.items(): + if ta != "999": + totals[ta] += population + actual = {} + for row in definition["rows"]: + codes = row["codes"] + cell = (codes["ta_code"], codes["region_code"], int(codes["as_area"])) + assert cell not in actual + assert cell[0] != "999" + assert codes["area"] == "|".join(map(str, cell)) + assert codes["population_code"] == f"nz-ta-{cell[0]}" + assert ( + row["target"] + == f"stats_nz_population_by_territorial_authority__ta{cell[0]}" + ) + actual[cell] = row["population_share"] + assert set(actual) == {cell for cell in cells if cell[0] != "999"} + for cell, share in actual.items(): + assert share == pytest.approx(cells[cell] / totals[cell[0]], rel=0, abs=1e-15) + + +def test_joint_support_uses_correlated_sa1_cells_and_preserves_outside_ta_audit() -> ( + None +): + placements, concordance, references = _fixture() + report = {} + definition = builder.aggregate_support( + placements, concordance, references, report=report + ) + _assert_support_matches_cells(definition, _expected(placements, concordance)) + assert [cell["population"] for cell in report["outside_ta_cells"]] == [33] + assert report["outside_ta_cells"][0]["area"] == "outside-ta|04|4" + assert report["outside_ta_sa1s"][0]["sa1_code"] == "fixture-5" + region99 = [cell for cell in report["cells"] if cell["region_code"] == "99"] + assert [(cell["ta_code"], cell["population"]) for cell in region99] == [ + ("067", 612) + ] + + +@pytest.mark.parametrize("different", ["ta", "region"]) +def test_sa1_concordance_refuses_multiple_joint_cells(different: str) -> None: + attributes = { + "SA12026_V1_00": "7000001", + "TA2026_V1_00": "020", + "REGC2025_V1_00": "03", + } + changed = dict(attributes) + changed["TA2026_V1_00" if different == "ta" else "REGC2025_V1_00"] = ( + "021" if different == "ta" else "08" + ) + with pytest.raises(ValueError, match="multiple.*cells"): + builder.joint_concordance([{"attributes": attributes}, {"attributes": changed}]) + assert builder.joint_concordance( + [{"attributes": attributes}, {"attributes": dict(attributes)}] + ) == {"7000001": {"ta_code": "020", "region_code": "03"}} + + +def test_zero_population_joint_cell_remains_explicit() -> None: + placements, concordance, references = _fixture() + placements.append( + {"sa1_code": "zero", "ta_code": "020", "as_area": 3, "population": 0} + ) + concordance["zero"] = {"ta_code": "020", "region_code": "08"} + definition = builder.aggregate_support(placements, concordance, references) + _assert_support_matches_cells(definition, _expected(placements, concordance)) + assert [ + row["population_share"] + for row in definition["rows"] + if row["codes"]["area"] == "020|08|3" + ] == [0] + + +@pytest.mark.parametrize( + "defect", + [ + "duplicate_sa1", + "missing_sa1", + "ta_disagreement", + "invalid_population", + "invalid_as_area", + "missing_anchor", + ], +) +def test_aggregation_refuses_ambiguous_incomplete_or_invalid_placements( + defect: str, +) -> None: + placements, concordance, references = _fixture() + if defect == "duplicate_sa1": + placements.append(dict(placements[0])) + elif defect == "missing_sa1": + del concordance[placements[0]["sa1_code"]] + elif defect == "ta_disagreement": + placements[0]["ta_code"] = "067" + elif defect == "invalid_population": + placements[0]["population"] = -1 + elif defect == "invalid_as_area": + placements[0]["as_area"] = 5 + else: + references = [ + reference + for reference in references + if reference["ledger_selector"]["geography_id"] != "nz-ta-020" + ] + with pytest.raises(ValueError): + builder.aggregate_support(placements, concordance, references) + + +def test_local_joint_page_sha_mismatch_refuses_before_using_changed_geography( + tmp_path: Path, +) -> None: + feature = { + "attributes": { + "MB2026_V1_00": "0000001", + "SA12026_V1_00": "7000001", + "TA2026_V1_00": "020", + "REGC2025_V1_00": "03", + } + } + payload = json.dumps({"features": [feature]}).encode() + page = tmp_path / "joint-page.json" + provenance = { + "pages": [ + { + "file": page.name, + "bytes": len(payload), + "sha256": hashlib.sha256(payload).hexdigest(), + "features": 1, + } + ] + } + page.write_bytes(payload) + assert builder.load_joint_sources(tmp_path, provenance) == [feature] + page.write_bytes(payload.replace(b'"03"', b'"08"')) + with pytest.raises(ValueError, match="SHA-256|sha256|hash"): + builder.load_joint_sources(tmp_path, provenance) + + +@pytest.mark.parametrize("drift", [None, "support", "report"]) +def test_cli_check_compares_exact_bytes_and_never_overwrites( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, drift: str | None +) -> None: + placements, concordance, references = _fixture() + report = {} + document = builder.aggregate_support( + placements, concordance, references, report=report + ) + + def generate(*args, **kwargs): + kwargs["report"].update(copy.deepcopy(report)) + return copy.deepcopy(document) + + monkeypatch.setattr(builder, "generate_support", generate) + output, audit = tmp_path / "support.json", tmp_path / "report.json" + output.write_bytes(builder._serialized(document)) + audit.write_bytes(builder._serialized(report)) + if drift is not None: + (output if drift == "support" else audit).write_bytes(b"drift\n") + before = { + path: (path.read_bytes(), path.stat().st_mtime_ns) for path in (output, audit) + } + arguments = [ + "--sources", + str(tmp_path), + "--joint-sources", + str(tmp_path), + "--out", + str(output), + "--report", + str(audit), + "--check", + ] + if drift is None: + assert builder.main(arguments) == 0 + else: + with pytest.raises(SystemExit) as error: + builder.main(arguments) + assert error.value.code == 1 + assert { + path: (path.read_bytes(), path.stat().st_mtime_ns) for path in (output, audit) + } == before + + +@pytest.mark.parametrize( + "mutant", + ["marginal_product", "region_from_ta", "drop_region_99", "ta999_as_real_ta"], +) +def test_joint_cell_oracle_rejects_mutants(mutant: str) -> None: + placements, concordance, references = _fixture() + definition = builder.aggregate_support(placements, concordance, references) + expected = _expected(placements, concordance) + _assert_support_matches_cells(definition, expected) + mutated = copy.deepcopy(definition) + if mutant == "marginal_product": + for row in mutated["rows"]: + if row["codes"]["ta_code"] == "020": + row["population_share"] = 0.25 + elif mutant == "region_from_ta": + for row in mutated["rows"]: + if row["codes"]["ta_code"] == "020": + row["codes"]["region_code"] = "03" + elif mutant == "drop_region_99": + mutated["rows"] = [ + row for row in mutated["rows"] if row["codes"]["region_code"] != "99" + ] + else: + row = copy.deepcopy(mutated["rows"][-1]) + row["codes"].update( + area="999|04|4", + ta_code="999", + region_code="04", + population_code="nz-ta-999", + ) + row["target"] = "stats_nz_population_by_territorial_authority__ta999" + mutated["rows"].append(row) + with pytest.raises(AssertionError): + _assert_support_matches_cells(mutated, expected) + + +def test_committed_definition_covers_exactly_the_published_ta_anchor_roster() -> None: + definition, references = _definition(), _references() + assert len(references) == 67 + assert {row["target"] for row in definition["rows"]} == { + row["name"] for row in references + } + assert definition["population_geography_level"] == "local_authority" + assert definition["population_code_column"] == "population_code" + assert definition["columns"]["area"]["relation"] == "exact" + assert definition["columns"]["as_area"]["relation"] == "best_fit" + areas = [row["codes"]["area"] for row in definition["rows"]] + assert len(areas) == len(set(areas)) + shares = defaultdict(list) + for row in definition["rows"]: + assert row["codes"]["ta_code"] != "999" + shares[row["target"]].append(row["population_share"]) + for group in shares.values(): + assert math.fsum(group) == pytest.approx(1, abs=definition["share_tolerance"]) + + +def test_actual_pinned_ta_erp_facts_compile_and_conserve_every_published_total() -> ( + None +): + artifact_path = os.environ.get("NZ_CHRONICLE_ARTIFACT") + if not artifact_path: + pytest.skip( + "Set NZ_CHRONICLE_ARTIFACT to replay the pinned published TA ERP facts" + ) + package = load_country_spec("nz") + assert "precal_references.json" in package.resources + assert "atomic_geography_support.json" in package.resources + reference_payload = (_SPEC / "precal_references.json").read_bytes() + assert ( + hashlib.sha256(reference_payload).hexdigest() + == package.resource_hashes["precal_references.json"] + ) + # CountrySpec's typed target_references projection is the calibration set; + # the separate precalibration resource supplies these published TA anchors. + references = [ + LedgerTargetReference(**row) + for row in json.loads(reference_payload)["target_references"] + if row["metadata"].get("precal_use") == "atomic_geography_support" + ] + artifact = load_ledger_consumer_artifact( + artifact_path, feed_pin=_read(_SPEC / "chronicle_feed.json") + ) + registry = compile_ledger_target_references( + artifact.facts, references, country="nz" + ) + surface = decode_target_surface( + encode_target_surface( + registry, + references, + references_sha256=package.resource_hashes["precal_references.json"], + facts=artifact.provenance(), + ) + ) + support = geography.decode_atomic_support( + support_from_surface(surface, _definition(), system="nz_published_ta_erp") + ) + assert len(registry.specs) == 67 + expected = {} + for target in registry.specs: + assert target.metadata["ledger_measure_unit"] == "count" + assert target.hierarchy is not None + assert target.hierarchy.geography.level == "local_authority" + code = target.hierarchy.geography.id + assert code != "nz-ta-999" + assert target.value.is_integer() + expected[code] = int(target.value) + actual = Counter() + for code, population in zip( + support.arrays["population_code"], support.arrays["population"], strict=True + ): + actual[code] += int(population) + assert actual == expected + assert sum(map(int, support.arrays["population"])) == sum(expected.values()) + + +@settings(max_examples=30, deadline=None, database=None) +@given( + first=st.integers(1, 1_000_000), + second=st.integers(1, 1_000_000), + order=st.permutations(tuple(range(5))), +) +def test_joint_support_apportions_arbitrary_anchor_totals_exactly( + first: int, second: int, order: tuple[int, ...] +) -> None: + placements, concordance, references = _fixture() + definition = builder.aggregate_support(placements, concordance, references) + surface = _surface(references, [first, second]) + payload = support_from_surface(surface, definition, system="nz_joint_fixture") + support = geography.decode_atomic_support(payload) + for reference, total in zip(references, (first, second), strict=True): + rows = [row for row in definition["rows"] if row["target"] == reference["name"]] + expected_shares = { + row["codes"]["area"]: Fraction(str(row["population_share"])) for row in rows + } + counts = { + area: int(population) + for area, population, code in zip( + support.arrays["area"], + support.arrays["population"], + support.arrays["population_code"], + strict=True, + ) + if code == reference["ledger_selector"]["geography_id"] + } + assert sum(counts.values()) == total + denominator = sum(expected_shares.values(), Fraction()) + for area, count in counts.items(): + assert ( + abs(Fraction(count) - total * expected_shares[area] / denominator) < 1 + ) + permuted = copy.deepcopy(definition) + permuted["rows"] = [definition["rows"][index] for index in order] + assert support_from_surface(surface, permuted, system="nz_joint_fixture") == payload + + +def test_committed_support_executes_atomic_assignment_derivation_and_gate() -> None: + definition, references = _definition(), _references() + support = geography.decode_atomic_support( + support_from_surface( + _surface(references, [1000] * len(references)), + definition, + system="nz_joint_fixture", + ) + ) + system = { + "id": "nz_joint_fixture", + "level": definition["level"], + "code_system": definition["code_system"], + "vintage": definition["vintage"], + "source": "fixture_support", + "selector": {}, + "constraints": [], + "observed_area": "observed_joint_area", + "stages": [{"level": "area", "weight": "population"}], + "layers": [ + { + "input": column, + "output": column, + **{ + key: definition["columns"][column][key] + for key in ("vintage", "relation", "source") + }, + } + for column in ("ta_code", "region_code", "as_area") + ], + } + specification = { + "version": 1, + "identity": ["household_id"], + "stream": ["sha256-u53-v1", "nz-joint-fixture", 0, 21], + "outputs": { + "area": "joint_area", + "system": "joint_system", + "basis": "joint_basis", + }, + "systems": [system], + } + households = pd.DataFrame( + { + "household_id": np.arange(len(support.arrays["area"])), + "observed_joint_area": support.arrays["area"], + } + ) + supports = {"nz_joint_fixture": support} + assigned = pd.concat( + [households, geography.assign_atomic(households, specification, supports)], + axis=1, + ) + completed = pd.concat( + [assigned, geography.derive_geography(assigned, specification, supports)], + axis=1, + ) + for column in ("ta_code", "region_code", "as_area"): + assert completed[column].tolist() == support.arrays[column].tolist() + assert ( + geography.validate_geography(completed, specification, supports)["outcome"] + == "pass" + ) + corrupted = completed.copy() + corrupted.loc[0, "region_code"] = "wrong" + with pytest.raises(ValueError, match="derived geography"): + geography.validate_geography(corrupted, specification, supports) + + +@pytest.fixture(scope="module") +def staged_joint() -> tuple[dict, dict, list[dict], dict, dict]: + source_name = os.environ.get("NZ_AS_AREA_SOURCES") + joint_name = os.environ.get("NZ_JOINT_GEOGRAPHY_SOURCES") + if not source_name or not joint_name: + pytest.skip( + "Set NZ_AS_AREA_SOURCES and NZ_JOINT_GEOGRAPHY_SOURCES for pinned-source replay" + ) + source_dir, joint_dir = Path(source_name), Path(joint_name) + if not source_dir.is_dir() or not joint_dir.is_dir(): + pytest.skip("Pinned-source directories are not available") + raw_population = {} + for page in sorted(source_dir.glob("sa1-2023-census-urp-p*.json")): + for feature in _read(page)["features"]: + attributes = feature["attributes"] + sa1 = attributes["SA12023_V1_00"] + assert sa1 not in raw_population + value = attributes["VAR_1_3"] + raw_population[sa1] = int(value) if value is not None and value >= 0 else 0 + raw_joint = {} + for page in sorted(joint_dir.glob("mbhg-2026-regc-p*.json")): + for feature in _read(page)["features"]: + attributes = feature["attributes"] + sa1 = attributes["SA12026_V1_00"] + joint = (attributes["TA2026_V1_00"], attributes["REGC2025_V1_00"]) + if sa1 in raw_joint: + assert raw_joint[sa1] == joint + raw_joint[sa1] = joint + report, placements = {}, [] + generated = builder.generate_support( + source_dir, joint_dir, report=report, placements=placements + ) + return generated, report, placements, raw_population, raw_joint + + +def test_fresh_pinned_generation_is_byte_identical_to_committed_support( + staged_joint, +) -> None: + generated, _, _, _, _ = staged_joint + assert ( + builder._serialized(generated) + == (_SPEC / "atomic_geography_support.json").read_bytes() + ) + + +def test_every_source_sa1_has_one_joint_cell_and_all_census_mass_is_accounted_for( + staged_joint, +) -> None: + generated, report, placements, raw_population, raw_joint = staged_joint + codes = [placement["sa1_code"] for placement in placements] + assert len(codes) == len(set(codes)) == len(raw_population) + assert set(codes) == set(raw_population) <= set(raw_joint) + expected = Counter() + for placement in placements: + sa1 = placement["sa1_code"] + ta, region = raw_joint[sa1] + assert placement["population"] == raw_population[sa1] + assert placement["ta_code"] == ta + expected[(ta, region, placement["as_area"])] += raw_population[sa1] + _assert_support_matches_cells(generated, expected) + audited = { + (cell["ta_code"], cell["region_code"], cell["as_area"]): cell["population"] + for cell in [*report["cells"], *report["outside_ta_cells"]] + } + assert audited == expected + assert sum(expected.values()) == 4_993_314 + assert ( + sum(count for (ta, _, _), count in expected.items() if ta != "999") == 4_993_281 + ) + assert sum(count for (ta, _, _), count in expected.items() if ta == "999") == 33 + assert { + row["sa1_code"]: row["population"] + for row in report["outside_ta_sa1s"] + if row["population"] + } == {"7022489": 3, "7022490": 30} + assert len(report["outside_ta_sa1s"]) == 7 + + +@pytest.mark.parametrize("ta", sorted(_STRADDLING)) +def test_each_straddling_ta_retains_exact_source_region_populations( + staged_joint, ta: str +) -> None: + _, report, _, populations, concordance = staged_joint + expected = Counter() + for sa1, population in populations.items(): + source_ta, region = concordance[sa1] + if source_ta == ta: + expected[region] += population + actual = { + row["region_code"]: row["population"] + for row in report["straddling_tas"] + if row["ta_code"] == ta + } + assert set(actual) == _STRADDLING[ta] + assert actual == expected + + +def test_region_totals_equal_sa1_sums_and_region99_has_its_own_ta067_mass( + staged_joint, +) -> None: + _, report, _, populations, concordance = staged_joint + expected = Counter() + for sa1, population in populations.items(): + expected[concordance[sa1][1]] += population + actual = {row["region_code"]: row["population"] for row in report["region_totals"]} + assert actual == expected + assert actual["99"] == 612 + assert { + (ta, region) + for sa1, (ta, region) in concordance.items() + if sa1 in populations and region == "99" and populations[sa1] + } == {("067", "99")} + + +def test_source_page_and_feature_permutations_leave_support_byte_identical( + staged_joint, +) -> None: + generated, _, placements, _, _ = staged_joint + directory = Path(os.environ["NZ_JOINT_GEOGRAPHY_SOURCES"]) + pages = [ + _read(page)["features"] + for page in sorted(directory.glob("mbhg-2026-regc-p*.json")) + ] + concordance = builder.joint_concordance( + [feature for page in reversed(pages) for feature in reversed(page)] + ) + permuted = builder.aggregate_support( + list(reversed(placements)), concordance, _references() + ) + assert builder._serialized(permuted) == builder._serialized(generated) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py index ae4c366f76..7ad30724de 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py @@ -222,6 +222,7 @@ def test_nz_generation_zero_views_come_from_the_country_spec_seam() -> None: assert {row.path for row in spec.resource_rows if row.kind == "legacy_json"} == { "as_area_crosswalk.json", "as_rate_bridge.json", + "atomic_geography_support.json", "axiom_input_closure.json", "axiom_rules_bindings.json", "benefit_unit_rule.json", diff --git a/packages/microcosm-build/tests/golden/nz_country_spec.json b/packages/microcosm-build/tests/golden/nz_country_spec.json index 8e59894571..75afcacff8 100644 --- a/packages/microcosm-build/tests/golden/nz_country_spec.json +++ b/packages/microcosm-build/tests/golden/nz_country_spec.json @@ -1,6 +1,6 @@ { "country": "nz", - "fingerprint": "5321c87b59a86b981a5b8fc00743719239ac5626f31fc5d9b6f07dc4eb6efb4c", + "fingerprint": "eb4221624170a0a1e00d73191eba34e15cd0bbc268894988360968debc56fd4c", "gate_ids": [ "calibration_per_family_fit", "demography_per_family_fit", @@ -40,16 +40,17 @@ "resource_hashes": { "as_area_crosswalk.json": "56eeb638d77c73fd92ca541d9d2f249fd3062bece0503470e0e85dde70c4c05b", "as_rate_bridge.json": "c6e21af7b090283431973a5610cc3adf5d783a4a01fb0051d5dc6c8347eeabb0", + "atomic_geography_support.json": "6efd09d5cde2f16d4d01e522a721191a829a754d2ce019d75bb0407085ecb4b7", "axiom_input_closure.json": "c3c164f437b05d598af7e604d2cb46365a8323a8043da49b08c5e0cdf32e2ec1", "axiom_rules_bindings.json": "72905af77132ff6a3c01ada4b6210be4c369d9c6dc49dc8c1b673e4bac0b5fb1", "benefit_unit_rule.json": "a9e8cbfd38a64d2f8db0002fe8c31bb5a18fb34dbe59fa943336487ce95e2ca8", "calibration_bindings.json": "ce69109c407de06899c9d47c2bebd2215b66c71777663f30dfb68a05af1634e6", "chronicle_feed.json": "60a80dd0042838b0412baf9dd0985c961b4253a6876d16bcdbb8a2c6c03de0c7", - "country_package.json": "f5df55b952debf849a3c0c1489257fd6d3ad8eb8064eb73f83babcd469ad8d21", + "country_package.json": "ba3341d06c39a6c2d103afc87ddf994177ee8884fefdd07ca98689e4c2621100", "currency_bridge.json": "aa6a4b286a6a1a015088f32ac013148553422c3d45eeef7d7a15af08388857ca", "export_contract.json": "2c7414fefe395c4f5822643dcd3bb3544ebb2040259aa007b828a99bd01ae210", "gates.json": "115f569914899cbf9dc13e2227e3eb8d21886821d63256082f1ec24dd8cc554c", - "geography_spine.json": "799bb85e0e4ef943b9f14c6223e2b6168d587e09d1fbf8c7ea2e1aaa0eaee17d", + "geography_spine.json": "5f2b1bdd9f8768249912ffd0fbcb2f7d4ed493b51c74306f793ec12441fd383f", "holdout_references.json": "52b5a2360502156da1392a68350e4e7f61b5fd420fa74428819b65886a9f8655", "precal_references.json": "ee3445f36111221b07441a170ecc8267f667b7ab787881804733a109a6f804e7", "reference_inventory.json": "a4796d19e44e6db37ba28499cd6b06e61be2bcab336aa352e8ce1cf2c2862735", @@ -60,7 +61,7 @@ "spec/bundle.yaml": "e9716ce827e9006d4efdc392e7aaf9cbc33c16112a8fbc423e8f3e74ec506d8e", "spec/catalogs.yaml": "3ab2025af39cba93ead707b9463e428430a45b30696a43d0906cbcd97ed36631", "spec/geography.yaml": "0dbf9f850dc3cef983f166bf6783022094894ec2461ad71f4809607bcfd390a9", - "spec/sources.yaml": "ee015a35820e4688c7325d24bf0dac0ad090226d15401d2e3b83bde4413561be", + "spec/sources.yaml": "afdaa4bef98cf520a1c72b6013d1e453162c761cd4b3c1548620184f6ba41297", "spec/spine.yaml": "b3e6a2832ff7671777cae113b7fc45f5e3492bb519526f229118d0851083533e", "spec/vintages.yaml": "1ecc1a3f952bd25b834c394314e8c933ddb5b095fd64ba492dddb03e3cdd803e", "target_references.json": "a987d5269f9f50026fbf92c506d914ae2c05fc8e4cc33595faaf466140f91e94" @@ -74,6 +75,7 @@ "spec/vintages.yaml", "as_area_crosswalk.json", "as_rate_bridge.json", + "atomic_geography_support.json", "axiom_input_closure.json", "axiom_rules_bindings.json", "benefit_unit_rule.json", diff --git a/tools/build_nz_as_area_crosswalk.py b/tools/build_nz_as_area_crosswalk.py index a375ca2968..725615e703 100644 --- a/tools/build_nz_as_area_crosswalk.py +++ b/tools/build_nz_as_area_crosswalk.py @@ -678,8 +678,14 @@ def _heading_conflicts( return conflicts, checks -def generate_crosswalk(source_dir, spec, report=None): - """Return a lean spec; fill a separate report with detailed audit evidence.""" +def generate_crosswalk(source_dir, spec, report=None, *, placements=None): + """Return a lean spec and optionally expose the identical SA1 placements. + + ``placements`` receives usable Census populations and the final AU-derived + AS areas, after the existing interior-point and alias resolutions. This + lets the joint-geography generator reuse this bridge without a second + placement rule or a change to the generated MC9 document. + """ groups, aliases = _load_sources(Path(source_dir), spec["provenance"]) sa1, au, ta = groups["sa1"], groups["au"], groups["ta"] populations, suppression = population_counts(sa1) @@ -840,7 +846,7 @@ def generate_crosswalk(source_dir, spec, report=None): ) document["rows"] = rows document["row_shape"].update( - population_total="sum of usable 2023 Census URP assigned to this TA; zero only for explicitly declared TA 999 placeholder", + population_total="sum of usable 2023 Census URP assigned to this TA; TA 999 has Census population 33, while no TA 999 ERP fact exists", modal_area="unique largest-population AS area, for scenario S3; ties refuse", ) document["unmatched_definition_entries"] = unmatched @@ -996,6 +1002,19 @@ def generate_crosswalk(source_dir, spec, report=None): if report is not None: report.clear() report.update(details) + if placements is not None: + placements.clear() + placements.extend( + { + "sa1_code": feature["attributes"][SA1_CODE], + "ta_code": ta_code, + "as_area": areas[au_code], + "population": int(population), + } + for feature, ta_code, au_code, population in zip( + sa1, ta_codes, au_codes, populations, strict=True + ) + ) return document diff --git a/tools/build_nz_joint_geography.py b/tools/build_nz_joint_geography.py new file mode 100644 index 0000000000..0c14843b8e --- /dev/null +++ b/tools/build_nz_joint_geography.py @@ -0,0 +1,376 @@ +"""Generate NZ's inactive TA x region x AS-area atomic support from pinned pages. + +This tool performs no network access. ``NZ_AS_AREA_SOURCES`` supplies the +existing G8-m interior-point/centroid placement inputs, and +``NZ_JOINT_GEOGRAPHY_SOURCES`` supplies the separately pinned MBHG REGC pages. +The executable definition has exactly the schema accepted by +``geography.support_from_facts@1``. The separate audit records Census counts, +including outside-TA residents that have no published TA population anchor. +""" + +from __future__ import annotations + +import argparse +import json +import os +from collections import Counter, defaultdict +from collections.abc import Mapping +from pathlib import Path + +from tools.build_nz_as_area_crosswalk import ( + CONCORDANCE_SA1_CODE, + CONCORDANCE_TA_CODE, + DEFAULT_SPEC, + generate_crosswalk, +) +from tools.fetch_nz_as_area_sources import JOINT_GEOGRAPHY_PROVENANCE, verify + +ROOT = Path(__file__).resolve().parents[1] +NZ = ROOT / "packages/microcosm-build/src/microcosm/build/nz" +DEFAULT_OUT = NZ / "atomic_geography_support.json" +DEFAULT_REPORT = ROOT / "docs/nz-joint-geography-report.json" +REGION_CODE = "REGC2025_V1_00" +MESHBLOCK_CODE = "MB2026_V1_00" +ATOMIC_VINTAGE = "ta2026_regc2025_au2017" + + +def load_joint_sources(source_dir, provenance=None): + """Verify every pinned page before reading its features; never trust receipts.""" + provenance = JOINT_GEOGRAPHY_PROVENANCE if provenance is None else provenance + pages = provenance["pages"] + names = [page["file"] for page in pages] + if not pages or len(names) != len(set(names)): + raise ValueError("Joint geography requires nonempty, unique pinned pages") + payloads = {} + for page in pages: + payload = (Path(source_dir) / page["file"]).read_bytes() + verify(page["file"], payload, page["sha256"], page["bytes"]) + payloads[page["file"]] = payload + features = [] + for page in sorted(pages, key=lambda page: page["file"]): + document = json.loads(payloads[page["file"]]) + if len(document["features"]) != page["features"]: + raise ValueError(f"Feature count mismatch: {page['file']}") + features.extend(document["features"]) + codes = [feature["attributes"][MESHBLOCK_CODE] for feature in features] + if len(codes) != len(set(codes)): + raise ValueError("Duplicate meshblock codes in joint-geography pages") + return sorted(features, key=lambda feature: feature["attributes"][MESHBLOCK_CODE]) + + +def joint_concordance(meshblock_features): + """Map each official SA1 to one TA x REGC cell, retaining region 99.""" + by_sa1 = defaultdict(set) + for feature in meshblock_features: + attributes = feature["attributes"] + sa1 = attributes[CONCORDANCE_SA1_CODE] + ta = attributes[CONCORDANCE_TA_CODE] + region = attributes[REGION_CODE] + for value, width in ((sa1, 7), (ta, 3), (region, 2)): + if not isinstance(value, str) or len(value) != width or not value.isdigit(): + raise ValueError("SA1, TA and REGC codes must be zero-padded digits") + by_sa1[sa1].add((ta, region)) + multiple = {sa1: sorted(cells) for sa1, cells in by_sa1.items() if len(cells) != 1} + if multiple: + raise ValueError(f"SA1 with multiple TA x REGC cells: {multiple}") + if not by_sa1: + raise ValueError("Joint geography requires an SA1 concordance") + return { + sa1: {"ta_code": next(iter(cells))[0], "region_code": next(iter(cells))[1]} + for sa1, cells in sorted(by_sa1.items()) + } + + +def _anchors(references): + if isinstance(references, Mapping): + references = references["target_references"] + anchors = {} + for reference in references: + if ( + reference.get("metadata", {}).get("precal_use") + != "atomic_geography_support" + ): + continue + selector = reference["ledger_selector"] + population_code = selector["geography_id"] + ta = population_code.removeprefix("nz-ta-") + if ( + selector["geography_level"] != "local_authority" + or population_code != f"nz-ta-{ta}" + or len(ta) != 3 + or not ta.isdigit() + or ta == "999" + or ta in anchors + ): + raise ValueError("Population anchors must be unique real TA hierarchy ids") + anchors[ta] = {"target": reference["name"], "population_code": population_code} + if not anchors: + raise ValueError("No eligible TA population anchors") + return anchors + + +def _definition(rows): + source = "Stats NZ Meshblock Higher Geographies 2026" + + def code(source, vintage, relation): + return { + "kind": "code", + "source": source, + "vintage": vintage, + "relation": relation, + } + + return { + "version": 1, + "level": "ta_region_as_area", + "code_system": "stats_nz_joint_ta_regc_as", + "vintage": ATOMIC_VINTAGE, + "columns": { + "area": code( + source + "; G8-m SA1 to AS placement", ATOMIC_VINTAGE, "exact" + ), + "ta_code": code(source, "ta_2026", "official_tabulation"), + "region_code": code(source, "regc_2025", "official_tabulation"), + "as_area": code( + "G8-m SA1 interior-point/centroid AU2017 bridge", "au_2017", "best_fit" + ), + "population_code": code( + "Stats NZ TA ERP target hierarchy", "ta_2025", "exact" + ), + "population": { + "kind": "weight", + "source": "Stats NZ TA ERP at 30 June 2025", + "basis": "TA ERP apportioned by within-TA 2023 Census SA1 usually resident population shares", + }, + }, + "rows": rows, + "share_tolerance": 1e-12, + "population_geography_level": "local_authority", + "population_code_column": "population_code", + } + + +def aggregate_support(placements, concordance, references, *, report=None): + """Aggregate observed joint cells, never a product of geography marginals. + + Zero-population cells remain explicit. TA 999 is audit-only because the + existing surface declares no outside-TA ERP target; its Census population + is counted separately rather than assigned to a real TA anchor. + """ + anchors = _anchors(references) + counts, sa1_counts = Counter(), Counter() + seen, outside_sa1s = set(), [] + for placement in sorted(placements, key=lambda row: row["sa1_code"]): + sa1, ta = placement["sa1_code"], placement["ta_code"] + population, as_area = placement["population"], placement["as_area"] + if sa1 in seen: + raise ValueError(f"Duplicate SA1 placement: {sa1}") + seen.add(sa1) + if sa1 not in concordance: + raise ValueError(f"Missing SA1 in TA x REGC concordance: {sa1}") + joint = concordance[sa1] + if ta != joint["ta_code"]: + raise ValueError(f"TA concordance disagreement for SA1 {sa1}") + if ta != "999" and ta not in anchors: + raise ValueError(f"No population anchor for real TA {ta}") + if type(population) is not int or population < 0: + raise ValueError("Usable SA1 population must be a nonnegative integer") + if type(as_area) is not int or as_area not in (1, 2, 3, 4): + raise ValueError("SA1 placement must declare AS area 1, 2, 3 or 4") + cell = (ta, joint["region_code"], as_area) + counts[cell] += population + sa1_counts[cell] += 1 + if ta == "999": + outside_sa1s.append({**placement, "region_code": joint["region_code"]}) + ta_population = Counter() + for (ta, _, _), population in counts.items(): + ta_population[ta] += population + missing = sorted(ta for ta in anchors if ta_population[ta] <= 0) + if missing: + raise ValueError( + f"Population anchors require positive usable SA1 population: {missing}" + ) + cells, outside_cells, rows = [], [], [] + for (ta, region, as_area), population in sorted(counts.items()): + area = f"{ta if ta != '999' else 'outside-ta'}|{region}|{as_area}" + cell = { + "area": area, + "ta_code": ta, + "region_code": region, + "as_area": as_area, + "population": population, + "sa1_count": sa1_counts[ta, region, as_area], + } + if ta == "999": + outside_cells.append(cell) + continue + cells.append(cell) + rows.append( + { + "target": anchors[ta]["target"], + "codes": { + "area": area, + "ta_code": ta, + "region_code": region, + "as_area": str(as_area), + "population_code": anchors[ta]["population_code"], + }, + "population_share": population / ta_population[ta], + } + ) + region_totals = defaultdict(lambda: Counter()) + ta_region_totals, ta_region_sa1s = Counter(), Counter() + regions_by_ta = defaultdict(set) + for (ta, region, as_area), population in counts.items(): + region_totals[region]["population"] += population + key = "outside_ta_population" if ta == "999" else "anchored_population" + region_totals[region][key] += population + if ta != "999": + regions_by_ta[ta].add(region) + ta_region_totals[ta, region] += population + ta_region_sa1s[ta, region] += sa1_counts[ta, region, as_area] + if report is not None: + report.clear() + report.update( + { + "description": "Generated by tools/build_nz_joint_geography.py; Census joint-cell audit, not a transport activation", + "population_basis": "Usable 2023 Census SA1 URP; suppressed/null observations contribute zero under the existing G8-m rule", + "anchor_basis": f"Existing {len(anchors)} real TA ERP references at 30 June 2025; largest-remainder apportionment preserves each TA ERP exactly", + "outside_ta_policy": "TA 999 has no declared ERP anchor; its own Census SA1s remain audit-only and are never reassigned to real TAs", + "sa1_count": len(seen), + "census_population": sum(counts.values()), + "anchored_census_population": sum(cell["population"] for cell in cells), + "outside_ta_population": sum( + cell["population"] for cell in outside_cells + ), + "atomic_cell_count": len(cells), + "cells": cells, + "outside_ta_cells": outside_cells, + "outside_ta_sa1s": outside_sa1s, + "ta_totals": [ + {"ta_code": ta, **anchor, "population": ta_population[ta]} + for ta, anchor in sorted(anchors.items()) + ], + "straddling_tas": [ + { + "ta_code": ta, + "region_code": region, + "population": population, + "sa1_count": ta_region_sa1s[ta, region], + } + for (ta, region), population in sorted(ta_region_totals.items()) + if len(regions_by_ta[ta]) > 1 + ], + "region_totals": [ + { + "region_code": region, + **{ + key: totals[key] + for key in ( + "population", + "anchored_population", + "outside_ta_population", + ) + }, + } + for region, totals in sorted(region_totals.items()) + ], + } + ) + return _definition(rows) + + +def generate_support( + source_dir, + joint_source_dir, + *, + spec=None, + precal_references=None, + provenance=None, + report=None, + placements=None, +): + """Return executable support and fill optional aggregate/placement evidence.""" + if spec is None: + spec = json.loads(DEFAULT_SPEC.read_text()) + if precal_references is None: + precal_references = json.loads((NZ / "precal_references.json").read_text()) + features = load_joint_sources(joint_source_dir, provenance) + concordance = joint_concordance(features) + assigned = [] + generate_crosswalk(source_dir, spec, placements=assigned) + document = aggregate_support( + assigned, concordance, precal_references, report=report + ) + if report is not None: + report["meshblock_count"] = len(features) + report["concordance_sa1_count"] = len(concordance) + report["concordance_sa1s_without_census"] = len(concordance) - len(assigned) + pins = JOINT_GEOGRAPHY_PROVENANCE if provenance is None else provenance + report["source_provenance"] = { + **pins, + "pages": sorted(pins["pages"], key=lambda page: page["file"]), + } + if placements is not None: + placements.clear() + placements.extend(assigned) + return document + + +def _serialized(document): + return (json.dumps(document, indent=2, ensure_ascii=False) + "\n").encode() + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--sources", type=Path, default=os.environ.get("NZ_AS_AREA_SOURCES") + ) + parser.add_argument( + "--joint-sources", + type=Path, + default=os.environ.get("NZ_JOINT_GEOGRAPHY_SOURCES"), + ) + parser.add_argument("--spec", type=Path, default=DEFAULT_SPEC) + parser.add_argument( + "--precal-references", type=Path, default=NZ / "precal_references.json" + ) + parser.add_argument("--out", type=Path, default=DEFAULT_OUT) + parser.add_argument("--report", type=Path, default=DEFAULT_REPORT) + parser.add_argument( + "--check", + action="store_true", + help="Refuse generated-file drift without writing", + ) + args = parser.parse_args(argv) + if any( + path is None or not path.is_dir() for path in (args.sources, args.joint_sources) + ): + parser.error( + "Supply pinned local pages with --sources and --joint-sources or their NZ_*_SOURCES variables" + ) + report = {} + document = generate_support( + args.sources, + args.joint_sources, + spec=json.loads(args.spec.read_text()), + precal_references=json.loads(args.precal_references.read_text()), + report=report, + ) + for path, generated in ((args.out, document), (args.report, report)): + payload = _serialized(generated) + if args.check: + if not path.is_file() or path.read_bytes() != payload: + parser.exit(1, f"Generated file drift: {path}\n") + else: + path.write_bytes(payload) + print( + f"{'Checked' if args.check else 'Generated'} {len(document['rows'])} joint atomic cells; " + f"{report['anchored_census_population']} anchored Census residents; " + f"{report['outside_ta_population']} audit-only outside-TA residents" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tools/fetch_nz_as_area_sources.py b/tools/fetch_nz_as_area_sources.py index 18063d51ce..e4ef764954 100644 --- a/tools/fetch_nz_as_area_sources.py +++ b/tools/fetch_nz_as_area_sources.py @@ -1,4 +1,4 @@ -"""Re-fetch the pinned Stats NZ pages behind MC9's Accommodation Supplement area bridge. +"""Re-fetch pinned Stats NZ Accommodation Supplement and joint-geography pages. ``tools/build_nz_as_area_crosswalk.py`` reads its inputs from a local directory and verifies every byte against the pins in ``nz/as_area_crosswalk.json``. The @@ -13,6 +13,11 @@ python tools/build_nz_as_area_crosswalk.py --sources nz-as-area-sources \ --out packages/microcosm-build/src/microcosm/build/nz/as_area_crosswalk.json +Use ``--joint-geography`` for the 29 Meshblock Higher Geographies 2026 pages +carrying the joint SA1, TA and REGC concordance. Their receipt pins below are +also consumed by the joint-support generator. ``--out`` defaults to +``NZ_JOINT_GEOGRAPHY_SOURCES`` in that mode, or ``NZ_AS_AREA_SOURCES`` otherwise. + Only public URLs are requested and no credentials are sent. """ @@ -21,6 +26,7 @@ import argparse import hashlib import json +import os import sys import time import urllib.request @@ -30,6 +36,217 @@ USER_AGENT = "PolicyEngine-microcosm/fetch_nz_as_area_sources" +# Stats NZ MBHG 2026, CC BY 4.0; receipts collected 2026-10-24. +JOINT_GEOGRAPHY_PROVENANCE = { + "pages": [ + { + "file": "mbhg-2026-regc-p000.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=0&resultRecordCount=2000", + "sha256": "e1e984283d49f4dba3757144e40b699796bf1c2ea1a34fb524015b56ba8a0b70", + "bytes": 521003, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p001.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=2000&resultRecordCount=2000", + "sha256": "33ad698c6e732312900b6303fa57e82ec5ea0f220038d583ff40d694a5a42241", + "bytes": 514300, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p002.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=4000&resultRecordCount=2000", + "sha256": "59961bdc25052d9a343643735da35609d677faf26194c2fd147eabcbc0e52d01", + "bytes": 510843, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p003.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=6000&resultRecordCount=2000", + "sha256": "7ed90527fba6c68a523e6db150e4cb129978a35676f8201a26f12e4533303ec2", + "bytes": 507377, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p004.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=8000&resultRecordCount=2000", + "sha256": "b7f1e845c837124b1a07e54b2c8b815c225a00deacc75f237b944e5e7d064f39", + "bytes": 510956, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p005.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=10000&resultRecordCount=2000", + "sha256": "a6e6514c2ac7537ab2d0b0158c200de564167b1599f80d7a7d570070b542e9dd", + "bytes": 508691, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p006.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=12000&resultRecordCount=2000", + "sha256": "ce785717911faccfab894dd49e9c2f692e73d42cee62909a2cc779d9db06ed1c", + "bytes": 506340, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p007.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=14000&resultRecordCount=2000", + "sha256": "ebcdf665068b37447bcddb629bc4d2f9bdff099113eae506fd922089f5b20aa8", + "bytes": 535730, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p008.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=16000&resultRecordCount=2000", + "sha256": "ee2f315e8979e745d6ed5c4b0c99901839366a793b4d9abcc9fd68c5897199c0", + "bytes": 528114, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p009.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=18000&resultRecordCount=2000", + "sha256": "06ccf71f83243bbae575b8055a89e08333bc78a5a1e2f509dab4251a7e05b7cf", + "bytes": 518165, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p010.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=20000&resultRecordCount=2000", + "sha256": "2e54c88fa2c53a4131605adf1a25268df62de4c9587164e56c669187f0b45792", + "bytes": 530076, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p011.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=22000&resultRecordCount=2000", + "sha256": "685e71a8b26fe2d33da66cadb350ab6de65daca0a4397bcc5699e4730dab5bfb", + "bytes": 542506, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p012.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=24000&resultRecordCount=2000", + "sha256": "a0829709d98edea532a5b8fd19371734e7a374e01341edc232ed62102dd8163c", + "bytes": 535178, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p013.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=26000&resultRecordCount=2000", + "sha256": "41d4db88e39694cc4354209f1bfff710f07f0dcd86aeb6f2d2830a025f803d4e", + "bytes": 514352, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p014.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=28000&resultRecordCount=2000", + "sha256": "b577cce44704864fc6bba62e088f766af70f8f5fc0725c7d2ee2afda6fa968e2", + "bytes": 523320, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p015.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=30000&resultRecordCount=2000", + "sha256": "aa5d2575c93d841a6d2119cad8bb18b41c681d7c94766f547733608004be53ff", + "bytes": 513997, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p016.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=32000&resultRecordCount=2000", + "sha256": "a2841c24d03b085993c6537bbe3d741275cc85b7f4c637469e193c39bbfc970d", + "bytes": 522196, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p017.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=34000&resultRecordCount=2000", + "sha256": "1e96c882a4e0a62665b88258e580790fc270f96bd30fb24fdc3c1057a005b01c", + "bytes": 521764, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p018.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=36000&resultRecordCount=2000", + "sha256": "cc7521961e6c58b76fde38b0f9d733b2cc548320507a3190dd7dd8064ed2a3cd", + "bytes": 501252, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p019.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=38000&resultRecordCount=2000", + "sha256": "21a908f590b627511552269556877575ebc07739e8ffcf5193b35f84c57f9e82", + "bytes": 520360, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p020.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=40000&resultRecordCount=2000", + "sha256": "5fa0fb56d80928156336393b16c2ded43723b2451a3beaa0bebf4405c4966e95", + "bytes": 521326, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p021.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=42000&resultRecordCount=2000", + "sha256": "1687f3810ac3e6d102cfcfba46a4a9144783d9e25dd53f65bfe5181a054eb756", + "bytes": 514036, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p022.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=44000&resultRecordCount=2000", + "sha256": "c86bdd6358ca59ebbd649d999757421225f8e6765ed9c77dc2068dfac76d93fa", + "bytes": 518806, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p023.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=46000&resultRecordCount=2000", + "sha256": "05b77539c17a8372244c5d32f198e5fccd5627283056df86edebbc33422996aa", + "bytes": 520836, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p024.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=48000&resultRecordCount=2000", + "sha256": "1677d482d346196e854dddea8b392d64f6966b96178ecaaf784ac561f65102f2", + "bytes": 521491, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p025.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=50000&resultRecordCount=2000", + "sha256": "b84a06ee52108d764dbcf2f952bfbae3a7b8bd78ca715f87e5ae4ca88115e1e7", + "bytes": 520123, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p026.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=52000&resultRecordCount=2000", + "sha256": "e10e772428ed3a9dbbb2c5f855c56d64503eb00da5a8b4201a1ca148a43ab4b7", + "bytes": 517802, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p027.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=54000&resultRecordCount=2000", + "sha256": "ebe3c768a5caa52a56a3a3ad4c0b2a2e060aa1839aa5a4f88bbd8a4bc07bf57e", + "bytes": 518919, + "features": 2000, + }, + { + "file": "mbhg-2026-regc-p028.json", + "url": "https://services2.arcgis.com/vKb0s8tBIA3bdocZ/arcgis/rest/services/Meshblock_Higher_Geographies_2026/FeatureServer/0/query?where=1%3D1&outFields=MB2026_V1_00,SA12026_V1_00,TA2026_V1_00,TA2026_V1_00_NAME,REGC2025_V1_00,REGC2025_V1_00_NAME,TALB2026_V1_00,TALB2026_V1_00_NAME&returnGeometry=false&f=json&orderByFields=OBJECTID&resultOffset=56000&resultRecordCount=2000", + "sha256": "a31cdd9e44109207e0e55e09ec515014e97b0b6dccb362578854e7eb57c0b05c", + "bytes": 409787, + "features": 1575, + }, + ], + "layers": [], +} + + def metadata_url(query_url): """Return the layer metadata endpoint for a FeatureServer query URL.""" if not query_url.endswith("/query"): @@ -101,13 +318,26 @@ def fetch_all(provenance, out_dir, fetch=_fetch): def main(argv=None): parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) - parser.add_argument("--spec", type=Path, default=SPEC) - parser.add_argument("--out", type=Path, required=True) + selector = parser.add_mutually_exclusive_group() + selector.add_argument("--spec", type=Path, default=SPEC) + selector.add_argument("--joint-geography", action="store_true") + parser.add_argument("--out", type=Path) args = parser.parse_args(argv) - provenance = json.loads(args.spec.read_text())["provenance"] - fetched = fetch_all(provenance, args.out) + source_env = ( + "NZ_JOINT_GEOGRAPHY_SOURCES" if args.joint_geography else "NZ_AS_AREA_SOURCES" + ) + out_dir = args.out or os.environ.get(source_env) + if out_dir is None: + parser.error(f"supply --out DIR or {source_env}=DIR") + out_dir = Path(out_dir) + provenance = ( + JOINT_GEOGRAPHY_PROVENANCE + if args.joint_geography + else json.loads(args.spec.read_text())["provenance"] + ) + fetched = fetch_all(provenance, out_dir) total = len(pinned_downloads(provenance)) - print(f"{total} pinned inputs verified in {args.out}; {len(fetched)} fetched") + print(f"{total} pinned inputs verified in {out_dir}; {len(fetched)} fetched") return 0