terraproof 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +356 -2
  3. package/bin/terraproof.js +4 -0
  4. package/dist/router/apply.js +147 -0
  5. package/dist/router/classify.js +111 -0
  6. package/dist/router/explain.js +9 -0
  7. package/dist/router/index.js +272 -0
  8. package/dist/router/resolve.js +239 -0
  9. package/dist/router/score.js +60 -0
  10. package/dist/router/types.js +1 -0
  11. package/dist/router/validate.js +81 -0
  12. package/instructions/engineering.md +14 -0
  13. package/instructions/security.md +14 -0
  14. package/instructions/simplicity.md +13 -0
  15. package/package.json +65 -4
  16. package/routing/DOMAIN_ROUTING.md +161 -0
  17. package/routing/ROUTER_DESIGN.md +173 -0
  18. package/routing/SKILL_MANIFEST.md +86 -0
  19. package/routing/checks.json +121 -0
  20. package/routing/collections.json +47 -0
  21. package/routing/registry.json +2211 -0
  22. package/routing/rules.json +64 -0
  23. package/skills/accuracy-assessment/SKILL.md +213 -0
  24. package/skills/accuracy-assessment/UPSTREAM.md +7 -0
  25. package/skills/accuracy-assessment/references/stratified-estimator.md +127 -0
  26. package/skills/accuracy-assessment/skill.json +103 -0
  27. package/skills/brainstorming/SKILL.md +250 -0
  28. package/skills/brainstorming/UPSTREAM.md +29 -0
  29. package/skills/brainstorming/scripts/frame-template.html +213 -0
  30. package/skills/brainstorming/scripts/helper.js +167 -0
  31. package/skills/brainstorming/scripts/server.cjs +723 -0
  32. package/skills/brainstorming/scripts/start-server.sh +209 -0
  33. package/skills/brainstorming/scripts/stop-server.sh +120 -0
  34. package/skills/brainstorming/skill.json +73 -0
  35. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  36. package/skills/brainstorming/visual-companion.md +299 -0
  37. package/skills/crs-and-units/SKILL.md +200 -0
  38. package/skills/crs-and-units/UPSTREAM.md +7 -0
  39. package/skills/crs-and-units/skill.json +74 -0
  40. package/skills/design-postgis-tables/SKILL.md +494 -0
  41. package/skills/design-postgis-tables/UPSTREAM.md +21 -0
  42. package/skills/design-postgis-tables/skill.json +90 -0
  43. package/skills/gdal/SKILL.md +125 -0
  44. package/skills/gdal/UPSTREAM.md +22 -0
  45. package/skills/gdal/references/gdal-recipes.md +103 -0
  46. package/skills/gdal/skill.json +66 -0
  47. package/skills/geomaster/README.md +105 -0
  48. package/skills/geomaster/SKILL.md +366 -0
  49. package/skills/geomaster/UPSTREAM.md +21 -0
  50. package/skills/geomaster/references/advanced-gis.md +376 -0
  51. package/skills/geomaster/references/big-data.md +363 -0
  52. package/skills/geomaster/references/code-examples.md +531 -0
  53. package/skills/geomaster/references/coordinate-systems.md +364 -0
  54. package/skills/geomaster/references/core-libraries.md +273 -0
  55. package/skills/geomaster/references/data-sources.md +330 -0
  56. package/skills/geomaster/references/gis-software.md +369 -0
  57. package/skills/geomaster/references/industry-applications.md +420 -0
  58. package/skills/geomaster/references/machine-learning.md +462 -0
  59. package/skills/geomaster/references/programming-languages.md +456 -0
  60. package/skills/geomaster/references/remote-sensing.md +370 -0
  61. package/skills/geomaster/references/scientific-domains.md +416 -0
  62. package/skills/geomaster/references/specialized-topics.md +428 -0
  63. package/skills/geomaster/references/troubleshooting.md +439 -0
  64. package/skills/geomaster/skill.json +157 -0
  65. package/skills/geopandas/SKILL.md +250 -0
  66. package/skills/geopandas/UPSTREAM.md +22 -0
  67. package/skills/geopandas/references/crs-management.md +231 -0
  68. package/skills/geopandas/references/data-io.md +323 -0
  69. package/skills/geopandas/references/data-structures.md +207 -0
  70. package/skills/geopandas/references/geometric-operations.md +262 -0
  71. package/skills/geopandas/references/spatial-analysis.md +294 -0
  72. package/skills/geopandas/references/visualization.md +230 -0
  73. package/skills/geopandas/scripts/_common.py +605 -0
  74. package/skills/geopandas/scripts/crs_reprojection_plan.py +210 -0
  75. package/skills/geopandas/scripts/export_plan.py +305 -0
  76. package/skills/geopandas/scripts/geometry_validity_report.py +227 -0
  77. package/skills/geopandas/scripts/sensitive_coordinates_checklist.py +230 -0
  78. package/skills/geopandas/scripts/spatial_join_audit.py +368 -0
  79. package/skills/geopandas/scripts/vector_inventory.py +140 -0
  80. package/skills/geopandas/skill.json +116 -0
  81. package/skills/geoparquet-validation/SKILL.md +125 -0
  82. package/skills/geoparquet-validation/UPSTREAM.md +24 -0
  83. package/skills/geoparquet-validation/references/distribution-best-practices.md +118 -0
  84. package/skills/geoparquet-validation/references/gpio-commands.md +264 -0
  85. package/skills/geoparquet-validation/references/tool-comparison.md +155 -0
  86. package/skills/geoparquet-validation/skill.json +71 -0
  87. package/skills/geospatial-data-discovery/SKILL.md +49 -0
  88. package/skills/geospatial-data-discovery/UPSTREAM.md +15 -0
  89. package/skills/geospatial-data-discovery/skill.json +51 -0
  90. package/skills/geospatial-frontend/SKILL.md +86 -0
  91. package/skills/geospatial-frontend/UPSTREAM.md +23 -0
  92. package/skills/geospatial-frontend/references/design-system.md +283 -0
  93. package/skills/geospatial-frontend/references/user-preferences.md +96 -0
  94. package/skills/geospatial-frontend/skill.json +87 -0
  95. package/skills/geozarr/SKILL.md +244 -0
  96. package/skills/geozarr/UPSTREAM.md +21 -0
  97. package/skills/geozarr/skill.json +97 -0
  98. package/skills/networkx/SKILL.md +440 -0
  99. package/skills/networkx/UPSTREAM.md +22 -0
  100. package/skills/networkx/references/algorithms.md +384 -0
  101. package/skills/networkx/references/generators.md +385 -0
  102. package/skills/networkx/references/graph-basics.md +284 -0
  103. package/skills/networkx/references/io.md +457 -0
  104. package/skills/networkx/references/visualization.md +531 -0
  105. package/skills/networkx/skill.json +93 -0
  106. package/skills/raster-processing/SKILL.md +222 -0
  107. package/skills/raster-processing/UPSTREAM.md +7 -0
  108. package/skills/raster-processing/skill.json +81 -0
  109. package/skills/sar-basics/SKILL.md +202 -0
  110. package/skills/sar-basics/UPSTREAM.md +7 -0
  111. package/skills/sar-basics/references/calibration-lut.md +98 -0
  112. package/skills/sar-basics/skill.json +97 -0
  113. package/skills/satellite-preprocessing/SKILL.md +241 -0
  114. package/skills/satellite-preprocessing/UPSTREAM.md +7 -0
  115. package/skills/satellite-preprocessing/skill.json +84 -0
  116. package/skills/scientific-visualization/SKILL.md +285 -0
  117. package/skills/scientific-visualization/UPSTREAM.md +25 -0
  118. package/skills/scientific-visualization/assets/color_palettes.py +263 -0
  119. package/skills/scientific-visualization/assets/nature.mplstyle +68 -0
  120. package/skills/scientific-visualization/assets/presentation.mplstyle +68 -0
  121. package/skills/scientific-visualization/assets/publication.mplstyle +77 -0
  122. package/skills/scientific-visualization/assets/publisher_profiles.json +269 -0
  123. package/skills/scientific-visualization/references/color_palettes.md +227 -0
  124. package/skills/scientific-visualization/references/journal_requirements.md +169 -0
  125. package/skills/scientific-visualization/references/matplotlib_examples.md +336 -0
  126. package/skills/scientific-visualization/references/publication_guidelines.md +196 -0
  127. package/skills/scientific-visualization/references/sources.md +76 -0
  128. package/skills/scientific-visualization/scripts/_common.py +136 -0
  129. package/skills/scientific-visualization/scripts/export_plan.py +493 -0
  130. package/skills/scientific-visualization/scripts/figure_export.py +642 -0
  131. package/skills/scientific-visualization/scripts/image_metadata.py +731 -0
  132. package/skills/scientific-visualization/scripts/palette_audit.py +327 -0
  133. package/skills/scientific-visualization/scripts/style_presets.py +501 -0
  134. package/skills/scientific-visualization/scripts/style_preview.py +232 -0
  135. package/skills/scientific-visualization/skill.json +95 -0
  136. package/skills/spectral-indices/SKILL.md +235 -0
  137. package/skills/spectral-indices/UPSTREAM.md +7 -0
  138. package/skills/spectral-indices/skill.json +88 -0
  139. package/skills/stac-and-cloud-access/SKILL.md +209 -0
  140. package/skills/stac-and-cloud-access/UPSTREAM.md +7 -0
  141. package/skills/stac-and-cloud-access/references/run-manifest.md +94 -0
  142. package/skills/stac-and-cloud-access/skill.json +98 -0
  143. package/skills/statistical-analysis/SKILL.md +446 -0
  144. package/skills/statistical-analysis/UPSTREAM.md +24 -0
  145. package/skills/statistical-analysis/references/assumptions_and_diagnostics.md +379 -0
  146. package/skills/statistical-analysis/references/bayesian_statistics.md +686 -0
  147. package/skills/statistical-analysis/references/effect_sizes_and_power.md +649 -0
  148. package/skills/statistical-analysis/references/reporting_standards.md +482 -0
  149. package/skills/statistical-analysis/references/test_selection_guide.md +129 -0
  150. package/skills/statistical-analysis/scripts/assumption_checks.py +652 -0
  151. package/skills/statistical-analysis/skill.json +127 -0
  152. package/skills/systematic-debugging/SKILL.md +283 -0
  153. package/skills/systematic-debugging/UPSTREAM.md +28 -0
  154. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  155. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  156. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  157. package/skills/systematic-debugging/find-polluter.sh +72 -0
  158. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  159. package/skills/systematic-debugging/skill.json +88 -0
  160. package/skills/time-series-and-change/SKILL.md +217 -0
  161. package/skills/time-series-and-change/UPSTREAM.md +7 -0
  162. package/skills/time-series-and-change/references/change-methods.md +42 -0
  163. package/skills/time-series-and-change/skill.json +116 -0
  164. package/skills/vector-quality/SKILL.md +204 -0
  165. package/skills/vector-quality/UPSTREAM.md +7 -0
  166. package/skills/vector-quality/skill.json +82 -0
  167. package/skills/verification/SKILL.md +120 -0
  168. package/skills/verification/UPSTREAM.md +31 -0
  169. package/skills/verification/skill.json +67 -0
  170. package/skills/writing-plans/SKILL.md +171 -0
  171. package/skills/writing-plans/UPSTREAM.md +23 -0
  172. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  173. package/skills/writing-plans/skill.json +80 -0
  174. package/sources/SOURCES.md +374 -0
  175. package/third_party/isaaccorley-geospatial-skills/LICENSE +176 -0
  176. package/third_party/isaaccorley-geospatial-skills/NOTICE.md +17 -0
  177. package/third_party/kdense-scientific-agent-skills/LICENSE +21 -0
  178. package/third_party/kdense-scientific-agent-skills/NOTICE.md +19 -0
  179. package/third_party/superpowers/LICENSE +21 -0
  180. package/third_party/superpowers/NOTICE.md +17 -0
  181. package/third_party/timescale-pg-aiguide/LICENSE +176 -0
  182. package/third_party/timescale-pg-aiguide/NOTICE.md +14 -0
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: time-series-and-change
3
+ description: Build analysis-ready satellite time series and detect change defensibly, covering per-observation masking and decoding, compositing, gap handling, temporal alignment, per-date index versus index of a composite, seasonality and phenology confounds, thresholded differences, trend and breakpoint methods, post-classification comparison and validation of change with reference data; use for multi-date optical or SAR monitoring, composites and change maps.
4
+ license: MIT
5
+ ---
6
+
7
+ # Time series and change detection
8
+
9
+ ## Define the change question first
10
+
11
+ State what change means (land-cover conversion, disturbance, flooding, gradual
12
+ trend), the minimum detectable size and magnitude, the period and the
13
+ observation frequency needed. Different change-detection procedures produce
14
+ different change maps even in the same environment [S1]; the question decides the
15
+ method, not the other way round. Reviews organise Landsat time-series change
16
+ detection by temporal frequency, preprocessing, algorithm and application [S2].
17
+
18
+ Related skills: [satellite preprocessing](../satellite-preprocessing/SKILL.md)
19
+ (decoding, QA masks, single-period composites),
20
+ [spectral indices](../spectral-indices/SKILL.md) (formulas, dNBR),
21
+ [SAR basics](../sar-basics/SKILL.md) (backscatter scales, orbit consistency),
22
+ [STAC and cloud access](../stac-and-cloud-access/SKILL.md) (search, loading,
23
+ provenance), [raster processing](../raster-processing/SKILL.md) (grids,
24
+ resampling), [accuracy assessment](../accuracy-assessment/SKILL.md) (validation).
25
+ Shared rules: [engineering](../../instructions/engineering.md),
26
+ [simplicity](../../instructions/simplicity.md), [security](../../instructions/security.md).
27
+
28
+ ## Build an analysis-ready time series
29
+
30
+ Process each observation **before** stacking or compositing:
31
+
32
+ 1. Decode scale/offset exactly once and mask fill, cloud, shadow and other QA
33
+ classes per sensor ([satellite preprocessing](../satellite-preprocessing/SKILL.md)).
34
+ Check whether your loader already decoded the data
35
+ ([STAC and cloud access](../stac-and-cloud-access/SKILL.md#know-what-your-loader-decodes)).
36
+ 2. Put all dates on **one grid** (CRS, transform, shape); categorical QA layers
37
+ with nearest neighbour.
38
+ 3. Merge tiles of the same acquisition into one observation (e.g. odc-stac
39
+ `groupby="solar_day"`) so overlaps are not counted as extra dates [S3].
40
+ 4. Keep one consistent product definition: processing level and baseline,
41
+ sensor, band (B08 vs B8A) and, for SAR, quantity/scale and relative orbit.
42
+ 5. Keep per-observation provenance: item id, acquisition time (UTC), processing
43
+ version and mask policy.
44
+
45
+ Store a **valid-observation count** per pixel and period beside every composite
46
+ or statistic. A median of two valid observations is not comparable with a median
47
+ of twenty.
48
+
49
+ ## Handle gaps without inventing data
50
+
51
+ - Invalid pixels stay nodata (NaN or a declared nodata), never 0 — zero is a
52
+ valid reflectance or index value.
53
+ - Set a minimum valid count per period and mask results below it; report the
54
+ masked fraction.
55
+ - Interpolation or gap filling is a model: label filled values, keep the
56
+ original count, and never treat filled values as observations in validation.
57
+ - Irregular sampling (orbit changes, constellation gaps, seasonal cloud) biases
58
+ composites towards the clearer part of a period; report the dates that
59
+ actually contributed.
60
+
61
+ ## Align observations in time
62
+
63
+ STAC `datetime` is UTC [S4]. Define periods (calendar months, 16-day windows,
64
+ seasons) explicitly, and whether an observation belongs to a period by its UTC
65
+ timestamp or local solar day. For bi-temporal change use comparable dates
66
+ (anniversary dates or the same phenological window), the same sensor geometry
67
+ (SAR: same relative orbit) and the same processing baseline where possible.
68
+
69
+ ## Composite of indices is not index of composite
70
+
71
+ For a nonlinear index such as NDVI, the median (or mean) of per-date indices
72
+ differs in general from the index of per-band composites, and per-band medians can
73
+ come from **different dates**. Three valid dates (red, NIR):
74
+ (0.05, 0.40), (0.10, 0.20), (0.04, 0.30):
75
+
76
+ ```text
77
+ per-date NDVI = 0.778, 0.333, 0.765 → median of NDVI = 0.765
78
+ median red, median NIR = 0.05 (date 1), 0.30 (date 3) → NDVI of medians = 0.714
79
+ ```
80
+
81
+ Pick one, name it in metadata and outputs, and use it consistently across
82
+ periods. A medoid or best-observation composite keeps real spectra from a single
83
+ date ([satellite preprocessing](../satellite-preprocessing/SKILL.md)). The code below computes both, with counts:
84
+
85
+ ```python
86
+ import numpy as np
87
+ import xarray as xr
88
+
89
+ def ndvi(red, nir):
90
+ den = nir + red
91
+ return ((nir - red) / den).where(den != 0)
92
+
93
+ def monthly_products(red, nir, min_obs=3):
94
+ """red, nir: decoded, masked reflectance (NaN = invalid), dims (time, y, x)."""
95
+ valid = np.isfinite(red) & np.isfinite(nir) & ((red + nir) != 0)
96
+ red, nir = red.where(valid), nir.where(valid)
97
+ count = valid.resample(time="1MS").sum()
98
+ median_of_ndvi = ndvi(red, nir).resample(time="1MS").median()
99
+ ndvi_of_median = ndvi(red.resample(time="1MS").median(),
100
+ nir.resample(time="1MS").median())
101
+ enough = count >= min_obs
102
+ return xr.Dataset({
103
+ "valid_count": count,
104
+ "median_of_ndvi": median_of_ndvi.where(enough),
105
+ "ndvi_of_median": ndvi_of_median.where(enough),
106
+ })
107
+ ```
108
+
109
+ Both products use the same observations: finite red/NIR pairs with a nonzero
110
+ NDVI denominator. Undefined per-date NDVI never increases `valid_count` or
111
+ satisfies `min_obs`. On the three dates above this returns 0.765 and 0.714 with
112
+ `valid_count` 3. For
113
+ Dask-backed arrays, test chunking along `time` before relying on median
114
+ reductions; write outputs with explicit nodata
115
+ ([raster processing](../raster-processing/SKILL.md)).
116
+
117
+ ## Separate seasonality and phenology from change
118
+
119
+ Vegetation indices, soil moisture, snow and water levels vary within the year.
120
+ A difference between a spring and a summer image is mostly phenology. Options:
121
+
122
+ - compare the same season or phenological stage across years;
123
+ - use a multi-year baseline per period (e.g. same month in prior years) and
124
+ express change as a departure from it;
125
+ - use models that represent seasonality explicitly (harmonic or seasonal terms),
126
+ as BFAST and CCDC do [S5, S6].
127
+
128
+ Also check for non-land-change causes: residual cloud/shadow, sensor or baseline
129
+ changes, illumination and view geometry, and (SAR) moisture and incidence angle.
130
+
131
+ ## Thresholded differences
132
+
133
+ Bi-temporal differencing (e.g. ΔNDVI, dNBR) or SAR log ratios
134
+ (`log10(date2/date1)` on linear power) is simple and transparent
135
+ ([spectral indices](../spectral-indices/SKILL.md), [SAR basics](../sar-basics/SKILL.md)).
136
+ The corresponding difference in dB is ten times that log ratio; declare the
137
+ units before selecting a threshold.
138
+
139
+ - Use the intersection of both dates' valid masks.
140
+ - No universal threshold exists; derive and document it for the study area
141
+ (reference data, histogram analysis) and report sensitivity to it.
142
+ - A difference measures signal change, not cause; interpret with the change
143
+ definition and validate.
144
+
145
+ ## Trend and breakpoint methods
146
+
147
+ Dense time-series methods model each pixel's trajectory and flag departures:
148
+
149
+ - **BFAST** decomposes a series into trend, seasonal and remainder components and
150
+ detects abrupt changes in the trend and seasonal components [S5].
151
+ - **CCDC** uses all available observations, iteratively fitting harmonic
152
+ functions and finding temporal breakpoints [S6, S7].
153
+ - **LandTrendr** temporally segments yearly Landsat trajectories into linear
154
+ segments to characterise disturbance and recovery [S8, S7].
155
+
156
+ Their parameters, input requirements and outputs are compared in
157
+ [references/change-methods.md](references/change-methods.md). Each needs a
158
+ consistent, well-masked series; gaps, undetected clouds and baseline changes
159
+ create false breaks. Treat their parameters as model choices to document and
160
+ test, not universal defaults.
161
+
162
+ ## Post-classification comparison
163
+
164
+ Comparing two independently classified maps labels every classification error
165
+ in either date as change, and the accuracies of the two single-date maps say
166
+ nothing about the accuracy of the change classes [S9]. Prefer mapping change
167
+ directly (time-series or multi-date classification). If maps must be compared,
168
+ assess the resulting change map itself.
169
+
170
+ ## Validate change with reference data
171
+
172
+ Change is usually rare, so assessment needs a probability sample **stratified by
173
+ the change map's classes** (e.g. loss, gain, stable) with enough units in the
174
+ change strata, reference labels that cover both dates, and area-adjusted
175
+ estimates with confidence intervals [S9, S10]. Follow
176
+ [accuracy assessment](../accuracy-assessment/SKILL.md); do not report change area
177
+ as a pixel count of the change map.
178
+
179
+ ## Verify with Terraproof
180
+
181
+ ```bash
182
+ python -m terraproof check ndvi_2023-06.tif ndvi_2024-06.tif --expect index
183
+ python -m terraproof check composite_count_2024-06.tif
184
+ python -m terraproof check source-item.json
185
+ ```
186
+
187
+ `raster.grid_alignment` (dates on one grid), `raster.nodata_declared`,
188
+ `crs.defined`/`crs.consistent`, `rs.index_range` (normalised indices, not dNBR or
189
+ differences), `rs.reflectance_range` (decoded reflectance composites) and
190
+ `stac.provenance` apply today.
191
+
192
+ For source Items, add `--time-range START END` to run `rs.temporal_scope`.
193
+ For individual decoded observations, `--qa QA.tif --qa-kind s2-scl` runs
194
+ `rs.cloud_mask_applied`; use `landsat-qa-pixel` for Landsat. Compare a decoded
195
+ observation to its raw source with `--reference-input RAW.tif --encoding s2-l2a`
196
+ or `landsat-c2-l2` for `rs.scale_applied_once`. These sampled pixel comparisons
197
+ do not validate a composite against a single acquisition's QA or raw DN.
198
+ `--manifest run.json --require-provenance` runs `provenance.reproducible`.
199
+ For change-map reference samples and estimates, follow the current CLI example
200
+ in [accuracy assessment](../accuracy-assessment/SKILL.md#verify-with-terraproof).
201
+
202
+ **Not checked automatically:** composite method and its consistency across
203
+ periods, valid-count thresholds, phenological comparability, change thresholds,
204
+ breakpoint-model parameters, and whether a detected change is real.
205
+
206
+ ## Sources
207
+
208
+ - [S1 — Singh, A. (1989). Digital change detection techniques using remotely-sensed data. International Journal of Remote Sensing 10(6):989–1003](https://doi.org/10.1080/01431168908903939): different procedures give different change maps.
209
+ - [S2 — Zhu, Z. (2017). Change detection using Landsat time series: a review of frequencies, preprocessing, algorithms, and applications. ISPRS J. Photogramm. Remote Sens. 130:370–384](https://doi.org/10.1016/j.isprsjprs.2017.06.013).
210
+ - [S3 — odc-stac `load`](https://odc-stac.readthedocs.io/en/latest/_api/odc.stac.load.html): `groupby="solar_day"` and fusing of overlapping items.
211
+ - [S4 — STAC Item specification](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md): `datetime` in UTC.
212
+ - [S5 — Verbesselt, J., Hyndman, R., Newnham, G., Culvenor, D. (2010). Detecting trend and seasonal changes in satellite image time series. Remote Sensing of Environment 114(1):106–115](https://doi.org/10.1016/j.rse.2009.08.014); [bfast package description](https://github.com/cran/bfast/blob/master/DESCRIPTION): trend/seasonal/remainder decomposition and break detection.
213
+ - [S6 — Zhu, Z., Woodcock, C.E. (2014). Continuous change detection and classification of land cover using all available Landsat data. Remote Sensing of Environment 144:152–171](https://doi.org/10.1016/j.rse.2014.01.011).
214
+ - [S7 — Google Earth Engine `ee.Algorithms.TemporalSegmentation.Ccdc`](https://developers.google.com/earth-engine/apidocs/ee-algorithms-temporalsegmentation-ccdc) and [`LandTrendr`](https://developers.google.com/earth-engine/apidocs/ee-algorithms-temporalsegmentation-landtrendr): harmonic-function breakpoints; temporal segmentation of spectral trajectories.
215
+ - [S8 — Kennedy, R.E., Yang, Z., Cohen, W.B. (2010). Detecting trends in forest disturbance and recovery using yearly Landsat time series: 1. LandTrendr. Remote Sensing of Environment 114(12):2897–2910](https://doi.org/10.1016/j.rse.2010.07.008).
216
+ - [S9 — FAO (2016). Map accuracy assessment and area estimation: a practical guide](https://www.fao.org/3/i5601e/i5601e.pdf): accuracy of change must be assessed on change, not on two single-date maps; stratification for change classes.
217
+ - [S10 — Olofsson, P. et al. (2014). Good practices for estimating area and assessing accuracy of land change. Remote Sensing of Environment 148:42–57](https://doi.org/10.1016/j.rse.2014.02.015).
@@ -0,0 +1,7 @@
1
+ # Attribution
2
+
3
+ Terraproof native — no upstream source.
4
+
5
+ Authored for Terraproof by Geova. License: MIT; see the [project license](../../LICENSE).
6
+ Primary technical references are listed in [SKILL.md](SKILL.md#sources).
7
+ No upstream skill text or code was copied or adapted.
@@ -0,0 +1,42 @@
1
+ # Change-detection approaches compared
2
+
3
+ Reference for [time series and change](../SKILL.md). Descriptions are limited to
4
+ what the cited method papers, package descriptions and implementation docs state;
5
+ check each implementation's own documentation for parameters.
6
+
7
+ | Approach | Input series | What it models | Typical output | Main failure modes |
8
+ |---|---|---|---|---|
9
+ | Thresholded difference / ratio (ΔNDVI, dNBR, SAR log ratio) | Two dates (or two composites) | Nothing; direct difference | Continuous change magnitude, thresholded to classes | Phenology mismatch, residual cloud, uncalibrated threshold, mask mismatch |
10
+ | Post-classification comparison | Two classified maps | Independent classifications | From–to change classes | Errors in either map become false change; single-date accuracy does not describe change accuracy [S5] |
11
+ | BFAST [S1] | Seasonal series; the package notes its BFAST Lite variant handles missing data without interpolation | Trend + seasonal + remainder; breaks in trend and seasonal components | Break dates, magnitudes, fitted piecewise models | Gaps/undetected clouds, irregular sampling, short series |
12
+ | CCDC [S2, S4] | All available clear observations | Harmonic functions fitted iteratively; temporal breakpoints | Segments with fit coefficients, break dates; breakpoint bands selectable | Undetected cloud/shadow, sparse observations, sensor/baseline shifts |
13
+ | LandTrendr [S3, S4] | One observation per year (e.g. annual composites) | Temporal segmentation of spectral trajectories into linear segments | Vertices (breakpoints), fitted values, disturbance/recovery segments | Inconsistent annual compositing, phenology in composites, one index drives breakpoints |
14
+
15
+ ## Choosing
16
+
17
+ - **Question:** abrupt events (fire, clearing, flood) suit differences or
18
+ breakpoint methods; gradual trends need models with trend terms over long
19
+ records; from–to classes need a classification step that maps change directly.
20
+ - **Data density:** dense methods need many clear observations; persistent cloud
21
+ or short records favour seasonal composites or SAR.
22
+ - **Consistency:** a single processing baseline, sensor harmonisation and stable
23
+ masks matter more than the algorithm; method reviews organise the choices by
24
+ frequency, preprocessing, algorithm and application [S6].
25
+ - **Validation:** every approach needs a reference sample stratified by the
26
+ change classes it produces and area-adjusted estimates [S5, S7].
27
+
28
+ ## Record for every run
29
+
30
+ Input ids and dates, masks, composite rule and valid counts, index or band,
31
+ method and version, parameters, thresholds with their derivation, and the
32
+ validation sample design.
33
+
34
+ ## Sources
35
+
36
+ - [S1 — Verbesselt et al. (2010), Remote Sensing of Environment 114(1):106–115](https://doi.org/10.1016/j.rse.2009.08.014); [bfast package description](https://github.com/cran/bfast/blob/master/DESCRIPTION).
37
+ - [S2 — Zhu & Woodcock (2014), Remote Sensing of Environment 144:152–171](https://doi.org/10.1016/j.rse.2014.01.011).
38
+ - [S3 — Kennedy, Yang & Cohen (2010), Remote Sensing of Environment 114(12):2897–2910](https://doi.org/10.1016/j.rse.2010.07.008).
39
+ - [S4 — Google Earth Engine CCDC](https://developers.google.com/earth-engine/apidocs/ee-algorithms-temporalsegmentation-ccdc) and [LandTrendr](https://developers.google.com/earth-engine/apidocs/ee-algorithms-temporalsegmentation-landtrendr) API documentation.
40
+ - [S5 — FAO (2016), Map accuracy assessment and area estimation: a practical guide](https://www.fao.org/3/i5601e/i5601e.pdf).
41
+ - [S6 — Zhu (2017), ISPRS J. Photogramm. Remote Sens. 130:370–384](https://doi.org/10.1016/j.isprsjprs.2017.06.013).
42
+ - [S7 — Olofsson et al. (2014), Remote Sensing of Environment 148:42–57](https://doi.org/10.1016/j.rse.2014.02.015).
@@ -0,0 +1,116 @@
1
+ {
2
+ "name": "time-series-and-change",
3
+ "layer": "domain",
4
+ "domains": [
5
+ "geospatial"
6
+ ],
7
+ "capabilities": [
8
+ "temporal-compositing",
9
+ "change-detection",
10
+ "gap-handling",
11
+ "breakpoint-detection"
12
+ ],
13
+ "triggers": [
14
+ "time series",
15
+ "time-series",
16
+ "median composite",
17
+ "change detection",
18
+ "change map",
19
+ "gap filling",
20
+ "breakpoint",
21
+ "landtrendr",
22
+ "ccdc",
23
+ "bfast",
24
+ "median of ndvi",
25
+ "ndvi of median",
26
+ "seasonal composite",
27
+ "post-classification comparison"
28
+ ],
29
+ "recommended": [
30
+ "satellite-preprocessing",
31
+ "accuracy-assessment"
32
+ ],
33
+ "requires": [],
34
+ "conflicts": [],
35
+ "explanation": "Builds analysis-ready multi-date optical or SAR series (per-observation decoding, compositing, gap and valid-count handling, temporal alignment) and detects change with differencing, trend/breakpoint methods, and reference-validated estimates.",
36
+ "sections": [
37
+ {
38
+ "id": "define-the-change-question-first",
39
+ "title": "Define the change question first",
40
+ "source": "SKILL.md#define-the-change-question-first"
41
+ },
42
+ {
43
+ "id": "build-an-analysis-ready-time-series",
44
+ "title": "Build an analysis-ready time series",
45
+ "source": "SKILL.md#build-an-analysis-ready-time-series"
46
+ },
47
+ {
48
+ "id": "handle-gaps-without-inventing-data",
49
+ "title": "Handle gaps without inventing data",
50
+ "source": "SKILL.md#handle-gaps-without-inventing-data"
51
+ },
52
+ {
53
+ "id": "align-observations-in-time",
54
+ "title": "Align observations in time",
55
+ "source": "SKILL.md#align-observations-in-time"
56
+ },
57
+ {
58
+ "id": "composite-of-indices-is-not-index-of-composite",
59
+ "title": "Composite of indices is not index of composite",
60
+ "source": "SKILL.md#composite-of-indices-is-not-index-of-composite"
61
+ },
62
+ {
63
+ "id": "separate-seasonality-and-phenology-from-change",
64
+ "title": "Separate seasonality and phenology from change",
65
+ "source": "SKILL.md#separate-seasonality-and-phenology-from-change"
66
+ },
67
+ {
68
+ "id": "thresholded-differences",
69
+ "title": "Thresholded differences",
70
+ "source": "SKILL.md#thresholded-differences"
71
+ },
72
+ {
73
+ "id": "trend-and-breakpoint-methods",
74
+ "title": "Trend and breakpoint methods",
75
+ "source": "SKILL.md#trend-and-breakpoint-methods"
76
+ },
77
+ {
78
+ "id": "post-classification-comparison",
79
+ "title": "Post-classification comparison",
80
+ "source": "SKILL.md#post-classification-comparison"
81
+ },
82
+ {
83
+ "id": "validate-change-with-reference-data",
84
+ "title": "Validate change with reference data",
85
+ "source": "SKILL.md#validate-change-with-reference-data"
86
+ },
87
+ {
88
+ "id": "verify-with-terraproof",
89
+ "title": "Verify with Terraproof",
90
+ "source": "SKILL.md#verify-with-terraproof"
91
+ },
92
+ {
93
+ "id": "sources",
94
+ "title": "Sources",
95
+ "source": "SKILL.md#sources"
96
+ },
97
+ {
98
+ "id": "change-methods",
99
+ "title": "Change methods",
100
+ "source": "references/change-methods.md"
101
+ }
102
+ ],
103
+ "checks": [
104
+ "rs.temporal_scope",
105
+ "rs.cloud_mask_applied",
106
+ "rs.scale_applied_once",
107
+ "raster.grid_alignment",
108
+ "raster.nodata_declared",
109
+ "rs.index_range",
110
+ "rs.reflectance_range",
111
+ "stac.provenance",
112
+ "accuracy.sample_design",
113
+ "accuracy.estimates",
114
+ "provenance.reproducible"
115
+ ]
116
+ }
@@ -0,0 +1,204 @@
1
+ ---
2
+ name: vector-quality
3
+ description: Audit and repair vector geometry and attribute quality while preserving feature identity and analytical scope; use before overlays, joins, measurement, coverage analysis, or GeoJSON export when invalid, missing, mixed, duplicate, or topologically inconsistent features could silently change results.
4
+ ---
5
+
6
+ # Vector quality
7
+
8
+ ## Inventory geometry and attribute states
9
+
10
+ Read the intended layer and retain a stable feature key. Count null geometries,
11
+ empty geometries, invalid non-null geometries, and geometry types separately.
12
+ Missing geometry (`None`) is not an empty geometry; an empty geometry may be
13
+ valid but unusable for the requested operation. Count attribute nulls independently.
14
+
15
+ ```python
16
+ import geopandas as gpd
17
+ import shapely
18
+
19
+ gdf = gpd.read_file("parcels.gpkg", engine="pyogrio")
20
+ g = gdf.geometry
21
+ present = g.notna()
22
+ print({
23
+ "records": len(gdf),
24
+ "null_geometry": int((~present).sum()),
25
+ "empty_geometry": int(g.is_empty.sum()),
26
+ "invalid_geometry": int((present & ~g.is_valid).sum()),
27
+ "types": g.geom_type.value_counts(dropna=False).to_dict(),
28
+ "attribute_nulls": gdf.drop(columns=g.name).isna().sum().to_dict(),
29
+ })
30
+ reasons = shapely.is_valid_reason(g.array)
31
+ ```
32
+
33
+ Distinguish Polygon from MultiPolygon even when both are acceptable polygonal
34
+ outputs. Inspect GeometryCollection members explicitly: a collection can hide
35
+ lower-dimensional remnants. A consistent type family is not proof of the
36
+ requested exact type, multipart policy, or dimensionality.
37
+
38
+ Use [GeoPandas](../geopandas/SKILL.md) for I/O and operation APIs, and
39
+ [CRS and units](../crs-and-units/SKILL.md) for metric tolerances. Follow the shared
40
+ [engineering](../../instructions/engineering.md), [simplicity](../../instructions/simplicity.md),
41
+ and [security](../../instructions/security.md) guidance rather than duplicating it.
42
+
43
+ ## Check validity before choosing a repair
44
+
45
+ OGC Simple Features polygon rules concern the represented region, not just a
46
+ closed coordinate list [S1]. Rings must be closed and simple; ring boundaries
47
+ must not cross. Holes must lie within their shell and polygon interiors must be
48
+ connected. MultiPolygon interiors must not overlap. Boundary-touch cases require
49
+ the actual OGC rules, not a blanket rule that all touching is invalid.
50
+
51
+ Use Shapely `is_valid` and `is_valid_reason` to diagnose individual features.
52
+ Planar topology ignores Z coordinates, so these checks do not audit elevation or M values.
53
+ A self-crossing LineString can be valid but non-simple; use `is_simple` when
54
+ network rules require no self-intersections. Feature validity alone does not
55
+ check whether adjacent cadastral polygons overlap or leave gaps.
56
+
57
+ Choose a repair based on intended geometry semantics, not simply whichever
58
+ method makes `is_valid` return true [S2]:
59
+
60
+ - `make_valid` linework repair preserves input edges/vertices but may produce
61
+ complex multipart output or a GeometryCollection.
62
+ - Structure repair reasons from shells and holes; it assumes their input roles
63
+ are correct. Check that the installed Shapely/GEOS supports the requested method.
64
+ - Collapsed rings can become lines/points or empties. Removing them is a scope
65
+ decision, not a neutral cleanup. Do not substitute `buffer(0)` as a universal
66
+ repair or assume it preserves the original region.
67
+
68
+ Minimal repair audit (default `make_valid` avoids version-specific method options):
69
+
70
+ ```python
71
+ import geopandas as gpd
72
+ import shapely
73
+
74
+ original = gpd.read_file("parcels.gpkg", engine="pyogrio")
75
+ repaired = original.copy()
76
+ needs_repair = original.geometry.notna() & ~original.geometry.is_valid
77
+ repaired.loc[needs_repair, original.geometry.name] = shapely.make_valid(
78
+ original.geometry.loc[needs_repair].array
79
+ )
80
+ print(original.geometry.geom_type.value_counts(dropna=False))
81
+ print(repaired.geometry.geom_type.value_counts(dropna=False))
82
+ print("empty_after", int(repaired.geometry.is_empty.sum()))
83
+ # Review changed regions and types before exporting repaired to a new dataset.
84
+ ```
85
+
86
+ Keep a before/after repair ledger keyed by feature ID. Compare type, parts,
87
+ empty/null state, and region changes in a justified measurement CRS; invalid
88
+ input areas are not a trustworthy ground truth. Export only after deciding how
89
+ to retain or quarantine lower-dimensional components. Do not silently explode
90
+ or drop them to meet a file format's schema. Audit whether Z and M values survive
91
+ repair and export, since repair and format conversion can drop or alter them.
92
+
93
+ ## Detect duplicate geometries without deleting legitimate records
94
+
95
+ Define duplication first: identical coordinate encoding, normalized structural
96
+ equality, or topological equality are different questions. Normalized WKB is a
97
+ useful candidate key, but topologically equal polygons with different vertex
98
+ segmentation can still have different encodings. Use Shapely `equals` on candidate
99
+ pairs for region equality [S3], with a spatial index for large layers.
100
+
101
+ Separate duplicate IDs, duplicate geometry, and duplicate full records. Two records
102
+ may share geometry legitimately (for example, different observations or rights).
103
+ Inspect attributes and ownership rules before deduplicating; record retained IDs
104
+ and every removal. Precision rounding is not an automatic duplicate detector.
105
+
106
+ ## Audit coverage topology: gaps, overlaps, and slivers
107
+
108
+ For a polygon coverage, validate individual inputs first and work in a suitable
109
+ shared CRS. Define the expected coverage boundary and legitimate holes before
110
+ labelling missing area a gap.
111
+
112
+ - Use spatial-index candidate pairs, then intersect polygon interiors; positive
113
+ intersection area indicates overlap, while shared edges alone are not overlap.
114
+ Exclude a feature paired with itself and count each pair once.
115
+ - Compare the union with the expected coverage boundary. Boundary minus union
116
+ identifies uncovered regions; union minus boundary identifies excess coverage.
117
+ The summed feature area versus union area is a useful overlap diagnostic, not
118
+ a map of each error or a substitute for pairwise inspection.
119
+ - Inspect narrow fragments generated by overlay. Set any sliver review threshold
120
+ from source accuracy and analytical purpose, not an arbitrary deletion cutoff.
121
+ - With a supporting Shapely version, `coverage_is_valid` and
122
+ `coverage_invalid_edges` help assess edge-matched, non-overlapping coverage.
123
+ Gaps may still be permitted by a coverage validator; check the intended boundary
124
+ explicitly [S4].
125
+
126
+ A valid union can conceal invalid relationships between the original records.
127
+ Do not fix a parcel coverage by dissolving away the ownership boundaries.
128
+
129
+ ## Choose precision and snapping deliberately
130
+
131
+ Precision grids and snapping tolerances are in coordinate units. Choose a grid
132
+ from the source accuracy and task tolerance after selecting a suitable CRS.
133
+ `shapely.set_precision` may remove repeated vertices, collapse narrow polygons,
134
+ or return empties [S5]. `shapely.snap` uses heuristics and does not guarantee valid
135
+ output. Validate again and compare feature scope and area after either operation.
136
+
137
+ Use a shared precision policy for overlay operands, but keep the original
138
+ coordinates. Coordinate decimal places do not establish positional accuracy.
139
+ Do not snap all layers to a basemap simply because the basemap looks cleaner.
140
+
141
+ ## Preserve records through null handling and joins
142
+
143
+ Audit required attribute nulls, blank strings and duplicate join keys separately.
144
+ For a many-parcels-to-one-owner join, reject null keys or explicitly route them to
145
+ an unmatched group before merging. A left join with `validate="many_to_one"` and
146
+ `indicator=True` can detect multiplied keys and unmatched records. Pandas may
147
+ match null keys to each other, unlike usual SQL null semantics [S6].
148
+
149
+ Track stable IDs as well as counts: an output can lose one record and duplicate
150
+ another while preserving total row count. Report unmatched left/right keys,
151
+ null-induced exclusions and one-to-many expansion. An intentional inner join or
152
+ `dropna` needs an explicit excluded-record ledger. A spatial join's boundary
153
+ predicate and duplicate matches need separate review; see
154
+ [GeoPandas API guidance](../geopandas/SKILL.md#core-api-decisions).
155
+
156
+ ## Export GeoJSON winding correctly
157
+
158
+ RFC 7946 requires WGS 84 longitude/latitude coordinates in decimal degrees and
159
+ right-hand winding: exterior rings counterclockwise, holes clockwise. A linear
160
+ ring has at least four positions and identical first/last positions [S7]. Winding
161
+ is not an OGC validity substitute. Readers should tolerate older opposite-wound
162
+ polygons, but producers should emit the RFC convention.
163
+
164
+ Use the GDAL GeoJSON driver's RFC mode after reviewing geometry quality:
165
+
166
+ ```bash
167
+ ogr2ogr -f GeoJSON -t_srs EPSG:4326 -lco RFC7946=YES parcels.geojson parcels_reviewed.gpkg
168
+ ```
169
+
170
+ Reopen and inspect the output rings, types, stable IDs and scope. RFC mode handles
171
+ antimeridian splitting, but precision reduction at export can still affect tiny
172
+ features. Do not export projected metre coordinates under a GeoJSON CRS label.
173
+
174
+ ## Verify with Terraproof
175
+
176
+ Use an installed Python core and substitute real local datasets:
177
+
178
+ ```bash
179
+ python -m terraproof check parcels.gpkg --format md --lang en --out vector-input-report.md
180
+ python -m terraproof check repaired.gpkg --compare-to parcels.gpkg
181
+ python -m terraproof check joined.gpkg --compare-to repaired.gpkg
182
+ ```
183
+
184
+ `geometry.valid` fails for invalid geometries. `geometry.non_empty` **warns** on
185
+ nulls or empties. `geometry.type_consistent` warns across type families, but
186
+ Polygon plus MultiPolygon is considered consistent. `scope.record_count` warns
187
+ on changed counts; it does not prove stable-ID preservation or join correctness.
188
+ `crs.defined` verifies CRS presence only.
189
+
190
+ Duplicate geometries, coverage gaps/overlaps/slivers, GeoJSON winding, precision
191
+ loss, attribute nulls, join-key/cardinality semantics, and repair fidelity are
192
+ **not checked automatically yet**. Add explicit audits for those requirements;
193
+ see [verification](../verification/SKILL.md).
194
+
195
+ ## Sources
196
+
197
+ - [S1 — OGC Simple Feature Access, Part 1, 06-103r4](https://docs.ogc.org/is/06-103r4/06-103r4.pdf): sections 6.1.11 and 6.1.14 define polygon/MultiPolygon validity; simplicity and topology definitions are in the common architecture.
198
+ - [S2 — Shapely make_valid](https://shapely.readthedocs.io/en/stable/reference/shapely.make_valid.html): linework/structure semantics and collapsed components.
199
+ - [S3 — Shapely equals](https://shapely.readthedocs.io/en/stable/reference/shapely.equals.html): topological equality independent of vertex ordering.
200
+ - [S4 — Shapely coverage_is_valid](https://shapely.readthedocs.io/en/stable/reference/shapely.coverage_is_valid.html): edge matching, overlap and gap-width semantics.
201
+ - [S5 — Shapely set_precision](https://shapely.readthedocs.io/en/stable/reference/shapely.set_precision.html) and [snap](https://shapely.readthedocs.io/en/stable/reference/shapely.snap.html): collapse and validity caveats.
202
+ - [S6 — pandas merge](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.merge.html): validation, indicator and null-key matching.
203
+ - [S7 — RFC 7946](https://www.rfc-editor.org/rfc/rfc7946): sections 3.1.6 and 4 specify four-position closed rings, winding and coordinates.
204
+ - [GDAL GeoJSON driver](https://gdal.org/en/stable/drivers/vector/geojson.html): RFC7946 layer creation option and export behavior.
@@ -0,0 +1,7 @@
1
+ # Attribution
2
+
3
+ Terraproof native — no upstream source.
4
+
5
+ Authored for Terraproof by Geova. License: MIT; see the [project license](../../LICENSE).
6
+ Primary technical references are listed in [SKILL.md](SKILL.md#sources).
7
+ No upstream skill text or code was copied or adapted.