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,439 @@
1
+ # GeoMaster Troubleshooting Guide
2
+
3
+ Solutions to common geospatial problems and debugging strategies.
4
+
5
+ ## Installation Issues
6
+
7
+ ### GDAL Installation Problems
8
+
9
+ ```bash
10
+ # Problem: "gdal-config not found" or rasterio install fails
11
+
12
+ # Solution 1: Use conda (recommended)
13
+ conda install -c conda-forge gdal rasterio
14
+
15
+ # Solution 2: System packages (Ubuntu/Debian)
16
+ sudo apt-get install gdal-bin libgdal-dev
17
+ export CPLUS_INCLUDE_PATH=/usr/include/gdal
18
+ export C_INCLUDE_PATH=/usr/include/gdal
19
+ uv pip install rasterio
20
+
21
+ # Solution 3: Wheel files
22
+ uv pip install rasterio --find-links=https://gis.wheelwrights.com/
23
+
24
+ # Verify installation
25
+ python -c "from osgeo import gdal; print(gdal.__version__)"
26
+ python -c "import rasterio; print(rasterio.__version__)"
27
+ ```
28
+
29
+ ### Python Binding Issues
30
+
31
+ ```bash
32
+ # Problem: "DLL load failed" on Windows
33
+ # Solution: Reinstall with conda
34
+ conda install -c conda-forge --force-reinstall gdal rasterio fiona
35
+
36
+ # Problem: "Symbol not found" on macOS
37
+ # Solution: Rebuild from source or use conda
38
+ brew install gdal
39
+ uv pip install rasterio --no-binary rasterio
40
+
41
+ # Problem: GEOS errors
42
+ brew install geos
43
+ uv pip install shapely --no-binary shapely
44
+ ```
45
+
46
+ ## Runtime Errors
47
+
48
+ ### CRS Transformation Errors
49
+
50
+ ```python
51
+ # Problem: "Invalid projection" or "CRS mismatch"
52
+ import geopandas as gpd
53
+
54
+ # Check CRS
55
+ print(f"CRS: {gdf.crs}")
56
+
57
+ # If None, set it
58
+ if gdf.crs is None:
59
+ gdf.set_crs("EPSG:4326", inplace=True)
60
+
61
+ # If unknown, try to detect
62
+ gdf = gdf.to_crs(gdf.estimate_utm_crs())
63
+ ```
64
+
65
+ ### Memory Errors with Large Rasters
66
+
67
+ ```python
68
+ # Problem: "MemoryError" when reading large files
69
+ # Solution: Read in chunks or use windows
70
+
71
+ import rasterio
72
+ from rasterio.windows import Window
73
+
74
+ # Windowed reading
75
+ with rasterio.open('large.tif') as src:
76
+ window = Window(0, 0, 1000, 1000) # (col_off, row_off, width, height)
77
+ subset = src.read(1, window=window)
78
+
79
+ # Block-by-block processing
80
+ with rasterio.open('large.tif') as src:
81
+ for i, window in src.block_windows(1):
82
+ block = src.read(1, window=window)
83
+ # Process block...
84
+
85
+ # Use Dask for very large files
86
+ import dask.array as da
87
+ dask_array = da.from_rasterio('large.tif', chunks=(1, 1024, 1024))
88
+ ```
89
+
90
+ ### Geometry Validation Errors
91
+
92
+ ```python
93
+ # Problem: "TopologyException" or "Self-intersection"
94
+ import geopandas as gpd
95
+ from shapely.validation import make_valid
96
+
97
+ # Check invalid geometries
98
+ invalid = gdf[~gdf.is_valid]
99
+ print(f"Invalid geometries: {len(invalid)}")
100
+
101
+ # Fix invalid geometries
102
+ gdf['geometry'] = gdf.geometry.make_valid()
103
+
104
+ # Buffer with 0 to fix (alternative method)
105
+ gdf['geometry'] = gdf.geometry.buffer(0)
106
+ ```
107
+
108
+ ### Coordinate Order Confusion
109
+
110
+ ```python
111
+ # Problem: Points in wrong location (lon/lat swapped)
112
+ from pyproj import Transformer
113
+
114
+ # Common mistake: lon, lat vs lat, lon
115
+ # Always specify axis order
116
+ transformer = Transformer.from_crs(
117
+ "EPSG:4326",
118
+ "EPSG:32610",
119
+ always_xy=True # Input: x=lon, y=lat (not y=lat, x=lon)
120
+ )
121
+
122
+ # Correct usage
123
+ x, y = transformer.transform(lon, lat) # not lat, lon
124
+ ```
125
+
126
+ ## Performance Issues
127
+
128
+ ### Slow Spatial Joins
129
+
130
+ ```python
131
+ # Problem: sjoin takes too long
132
+ import geopandas as gpd
133
+
134
+ # Solution: Use spatial index
135
+ gdf1.sindex # Auto-created
136
+ gdf2.sindex
137
+
138
+ # For nearest neighbor joins, use specialized function
139
+ result = gpd.sjoin_nearest(gdf1, gdf2, max_distance=1000)
140
+
141
+ # Use intersection predicate (faster than 'intersects' for points)
142
+ result = gpd.sjoin(points, polygons, predicate='within')
143
+
144
+ # Clip to bounding box first
145
+ bbox = gdf1.total_bounds
146
+ gdf2_clipped = gdf2.cx[bbox[0]:bbox[2], bbox[1]:bbox[3]]
147
+ result = gpd.sjoin(gdf1, gdf2_clipped, predicate='intersects')
148
+ ```
149
+
150
+ ### Slow Raster I/O
151
+
152
+ ```python
153
+ # Problem: Reading/writing rasters is slow
154
+ import rasterio
155
+
156
+ # Solution 1: Use compression when writing
157
+ profile.update(
158
+ compress='DEFLATE',
159
+ predictor=2,
160
+ zlevel=4
161
+ )
162
+
163
+ # Solution 2: Use tiled output
164
+ profile.update(
165
+ tiled=True,
166
+ blockxsize=256,
167
+ blockysize=256
168
+ )
169
+
170
+ # Solution 3: Enable caching
171
+ from osgeo import gdal
172
+ gdal.SetCacheMax(2**30) # 1GB
173
+
174
+ # Solution 4: Use COG format for cloud access
175
+ from rio_cogeo.cogeo import cog_translate
176
+ cog_translate('input.tif', 'output.tif', profile)
177
+ ```
178
+
179
+ ### Slow Reprojection
180
+
181
+ ```python
182
+ # Problem: to_crs() is very slow
183
+ import geopandas as gpd
184
+
185
+ # Solution 1: Simplify geometry first
186
+ gdf_simple = gdf.geometry.simplify(tolerance=0.0001)
187
+ gdf_reproj = gdf_simple.to_crs(target_crs)
188
+
189
+ # Solution 2: Use lower precision for display
190
+ gdf_reproj = gdf.to_crs(target_crs, geometry_precision=2)
191
+
192
+ # Solution 3: Reproject in parallel
193
+ import multiprocessing as mp
194
+ from functools import partial
195
+
196
+ def reproj_chunk(chunk, target_crs):
197
+ return chunk.to_crs(target_crs)
198
+
199
+ chunks = np.array_split(gdf, mp.cpu_count())
200
+ with mp.Pool() as pool:
201
+ results = pool.map(partial(reproj_chunk, target_crs=target_crs), chunks)
202
+ gdf_reproj = gpd.GeoDataFrame(pd.concat(results))
203
+ ```
204
+
205
+ ## Common Pitfalls
206
+
207
+ ### Area in Degrees
208
+
209
+ ```python
210
+ # WRONG: Area in square degrees
211
+ gdf = gpd.read_file('data.geojson')
212
+ area = gdf.geometry.area # Wrong!
213
+
214
+ # CORRECT: Use projected CRS
215
+ gdf_proj = gdf.to_crs(gdf.estimate_utm_crs())
216
+ area_sqm = gdf_proj.geometry.area
217
+ area_sqkm = area_sqm / 1_000_000
218
+ ```
219
+
220
+ ### Buffer in Geographic CRS
221
+
222
+ ```python
223
+ # WRONG: Buffer of 1000 degrees
224
+ gdf['buffer'] = gdf.geometry.buffer(1000)
225
+
226
+ # CORRECT: Project first
227
+ gdf_proj = gdf.to_crs("EPSG:32610")
228
+ gdf_proj['buffer_km'] = gdf_proj.geometry.buffer(1000) # 1000 meters
229
+ ```
230
+
231
+ ### Web Mercator Distortion
232
+
233
+ ```python
234
+ # WRONG: Area calculation in Web Mercator
235
+ gdf = gdf.to_crs("EPSG:3857")
236
+ area = gdf.geometry.area # Significant distortion!
237
+
238
+ # CORRECT: Use appropriate projection
239
+ gdf = gdf.to_crs(gdf.estimate_utm_crs())
240
+ area = gdf.geometry.area # Accurate
241
+ ```
242
+
243
+ ### Mixing CRS
244
+
245
+ ```python
246
+ # WRONG: Spatial join without checking CRS
247
+ result = gpd.sjoin(gdf1, gdf2, predicate='intersects')
248
+
249
+ # CORRECT: Ensure same CRS
250
+ if gdf1.crs != gdf2.crs:
251
+ gdf2 = gdf2.to_crs(gdf1.crs)
252
+ result = gpd.sjoin(gdf1, gdf2, predicate='intersects')
253
+ ```
254
+
255
+ ## Data Issues
256
+
257
+ ### Missing/Missing CRS
258
+
259
+ ```python
260
+ # Problem: CRS is None
261
+ gdf = gpd.read_file('data.geojson')
262
+ if gdf.crs is None:
263
+ # Try to detect from data extent
264
+ lon_min, lat_min, lon_max, lat_max = gdf.total_bounds
265
+
266
+ if -180 <= lon_min <= 180 and -90 <= lat_min <= 90:
267
+ gdf.set_crs("EPSG:4326", inplace=True)
268
+ print("Assumed WGS 84 (EPSG:4326)")
269
+ else:
270
+ gdf.set_crs(gdf.estimate_utm_crs(), inplace=True)
271
+ print("Estimated UTM zone")
272
+ ```
273
+
274
+ ### Invalid Coordinates
275
+
276
+ ```python
277
+ # Problem: Coordinates out of valid range
278
+ gdf = gpd.read_file('data.geojson')
279
+
280
+ # Check for invalid coordinates
281
+ invalid_lon = (gdf.geometry.x < -180) | (gdf.geometry.x > 180)
282
+ invalid_lat = (gdf.geometry.y < -90) | (gdf.geometry.y > 90)
283
+
284
+ if invalid_lon.any() or invalid_lat.any():
285
+ print("Warning: Invalid coordinates found")
286
+ gdf = gdf[~invalid_lon & ~invalid_lat]
287
+ ```
288
+
289
+ ### Empty Geometries
290
+
291
+ ```python
292
+ # Problem: Processing fails with empty geometries
293
+ # Remove empty geometries
294
+ gdf = gdf[~gdf.geometry.is_empty]
295
+
296
+ # Or fill with None
297
+ gdf.loc[gdf.geometry.is_empty, 'geometry'] = None
298
+
299
+ # Check before operations
300
+ if gdf.geometry.is_empty.any():
301
+ print(f"Warning: {gdf.geometry.is_empty.sum()} empty geometries")
302
+ ```
303
+
304
+ ## Remote Sensing Issues
305
+
306
+ ### Sentinel-2 Band Ordering
307
+
308
+ ```python
309
+ # Problem: Wrong band indices
310
+ # Sentinel-2 L2A SAFE structure:
311
+ # B01 (60m), B02 (10m), B03 (10m), B04 (10m), B05 (20m),
312
+ # B06 (20m), B07 (20m), B08 (10m), B08A (20m), B09 (60m),
313
+ # B11 (20m), B12 (20m)
314
+
315
+ # Sentinel-2 (resampled to 10m):
316
+ # B02=1, B03=2, B04=3, B05=4, B06=5, B07=6, B08=7, B8A=8, B11=9, B12=10
317
+
318
+ # For 10m bands only:
319
+ blue = src.read(1) # B02
320
+ green = src.read(2) # B03
321
+ red = src.read(3) # B04
322
+ nir = src.read(4) # B08
323
+ ```
324
+
325
+ ### Cloud Shadow Masking
326
+
327
+ ```python
328
+ # Problem: Clouds and shadows not properly masked
329
+ def improved_cloud_mask(scl):
330
+ """
331
+ Improved cloud masking using SCL layer.
332
+ Classes: 0=No data, 1=Saturated, 2=Dark, 3=Cloud shadow,
333
+ 4=Vegetation, 5=Bare soil, 6=Water, 7=Cloud low prob,
334
+ 8=Cloud med prob, 9=Cloud high prob, 10=Thin cirrus
335
+ """
336
+ # Mask: clouds, cloud shadows, saturated
337
+ mask = scl.isin([0, 1, 3, 8, 9, 10])
338
+ return mask
339
+
340
+ # Apply
341
+ scl = s2_image.select('SCL')
342
+ cloud_mask = improved_cloud_mask(scl)
343
+ image_clean = s2_image.updateMask(cloud_mask.Not())
344
+ ```
345
+
346
+ ## Error Messages Reference
347
+
348
+ | Error | Cause | Solution |
349
+ |-------|-------|----------|
350
+ | `CRS mismatch` | Different coordinate systems | `gdf2 = gdf2.to_crs(gdf1.crs)` |
351
+ | `TopologyException` | Invalid/self-intersecting geometry | `gdf.geometry = gdf.geometry.make_valid()` |
352
+ | `MemoryError` | Large dataset | Use Dask or chunked reading |
353
+ | `Invalid projection` | Unknown CRS code | Check EPSG code, use `CRS.from_user_input()` |
354
+ | `Empty geometry` | Null geometries | `gdf = gdf[~gdf.geometry.is_empty]` |
355
+ | `Bounds error` | Coordinates out of range | Filter invalid coordinates |
356
+ | `DLL load failed` | GDAL not installed | Use conda: `conda install gdal` |
357
+ | `Symbol not found` | Library linking issue | Reinstall with binary wheels or conda |
358
+ | `Self-intersection` | Invalid polygon | Buffer(0) or make_valid() |
359
+
360
+ ## Debugging Strategies
361
+
362
+ ### 1. Check Data Integrity
363
+
364
+ ```python
365
+ def check_geodataframe(gdf):
366
+ """Comprehensive GeoDataFrame health check."""
367
+ print(f"Shape: {gdf.shape}")
368
+ print(f"CRS: {gdf.crs}")
369
+ print(f"Bounds: {gdf.total_bounds}")
370
+ print(f"Invalid geometries: {(~gdf.is_valid).sum()}")
371
+ print(f"Empty geometries: {gdf.geometry.is_empty.sum()}")
372
+ print(f"None geometries: {gdf.geometry.isna().sum()}")
373
+ print(f"Duplicate geometries: {gdf.geometry.duplicated().sum()}")
374
+ print("\nGeometry types:")
375
+ print(gdf.geometry.type.value_counts())
376
+ print("\nCoordinate range:")
377
+ print(f" X: {gdf.geometry.x.min():.2f} to {gdf.geometry.x.max():.2f}")
378
+ print(f" Y: {gdf.geometry.y.min():.2f} to {gdf.geometry.y.max():.2f}")
379
+
380
+ check_geodataframe(gdf)
381
+ ```
382
+
383
+ ### 2. Test Transformations
384
+
385
+ ```python
386
+ def test_reprojection(gdf, target_crs):
387
+ """Test if reprojection is reversible."""
388
+ original = gdf.copy()
389
+ gdf_proj = gdf.to_crs(target_crs)
390
+ gdf_back = gdf_proj.to_crs(gdf.crs)
391
+
392
+ diff = original.geometry.distance(gdf_back.geometry).max()
393
+ if diff > 1: # More than 1 meter
394
+ print(f"Warning: Max error: {diff:.2f}m")
395
+ return False
396
+ return True
397
+ ```
398
+
399
+ ### 3. Profile Code
400
+
401
+ ```python
402
+ import time
403
+
404
+ def time_operation(func, *args, **kwargs):
405
+ """Time a geospatial operation."""
406
+ start = time.time()
407
+ result = func(*args, **kwargs)
408
+ elapsed = time.time() - start
409
+ print(f"{func.__name__}: {elapsed:.2f}s")
410
+ return result
411
+
412
+ # Usage
413
+ time_operation(gdf.to_crs, "EPSG:32610")
414
+ ```
415
+
416
+ ## Getting Help
417
+
418
+ ### Check Versions
419
+
420
+ ```python
421
+ import sys
422
+ import geopandas as gpd
423
+ import rasterio
424
+ from osgeo import gdal
425
+
426
+ print(f"Python: {sys.version}")
427
+ print(f"GeoPandas: {gpd.__version__}")
428
+ print(f"Rasterio: {rasterio.__version__}")
429
+ print(f"GDAL: {gdal.__version__}")
430
+ print(f"PROJ: {gdal.VersionInfo('PROJ')}")
431
+ ```
432
+
433
+ ### Useful Resources
434
+
435
+ - **GeoPandas docs**: https://geopandas.org/
436
+ - **Rasterio docs**: https://rasterio.readthedocs.io/
437
+ - **PROJ datab**: https://epsg.org/
438
+ - **Stack Overflow**: Tag with `gis` and `python`
439
+ - **GIS Stack Exchange**: https://gis.stackexchange.com/
@@ -0,0 +1,157 @@
1
+ {
2
+ "name": "geomaster",
3
+ "layer": "domain",
4
+ "domains": [
5
+ "geospatial",
6
+ "remote-sensing"
7
+ ],
8
+ "capabilities": [
9
+ "earth-observation",
10
+ "satellite-processing",
11
+ "sentinel",
12
+ "landsat",
13
+ "terrain-analysis",
14
+ "spatial-ml"
15
+ ],
16
+ "triggers": [
17
+ "remote sensing",
18
+ "satellite",
19
+ "sentinel",
20
+ "landsat",
21
+ "earth observation",
22
+ "ndvi",
23
+ "elevation dem",
24
+ "point cloud lidar",
25
+ "spatial modeling"
26
+ ],
27
+ "recommended": [
28
+ "verification"
29
+ ],
30
+ "requires": [],
31
+ "conflicts": [],
32
+ "explanation": "Provides Earth observation, satellite imagery, remote sensing, and spatial ML guidance.",
33
+ "sections": [
34
+ {
35
+ "id": "installation",
36
+ "title": "Installation",
37
+ "source": "SKILL.md#installation"
38
+ },
39
+ {
40
+ "id": "quick-start",
41
+ "title": "Quick Start",
42
+ "source": "SKILL.md#quick-start"
43
+ },
44
+ {
45
+ "id": "core-concepts",
46
+ "title": "Core Concepts",
47
+ "source": "SKILL.md#core-concepts"
48
+ },
49
+ {
50
+ "id": "common-operations",
51
+ "title": "Common Operations",
52
+ "source": "SKILL.md#common-operations"
53
+ },
54
+ {
55
+ "id": "image-classification",
56
+ "title": "Image Classification",
57
+ "source": "SKILL.md#image-classification"
58
+ },
59
+ {
60
+ "id": "modern-cloud-native-workflows",
61
+ "title": "Modern Cloud-Native Workflows",
62
+ "source": "SKILL.md#modern-cloud-native-workflows"
63
+ },
64
+ {
65
+ "id": "performance-tips",
66
+ "title": "Performance Tips",
67
+ "source": "SKILL.md#performance-tips"
68
+ },
69
+ {
70
+ "id": "best-practices",
71
+ "title": "Best Practices",
72
+ "source": "SKILL.md#best-practices"
73
+ },
74
+ {
75
+ "id": "detailed-documentation",
76
+ "title": "Detailed Documentation",
77
+ "source": "SKILL.md#detailed-documentation"
78
+ },
79
+ {
80
+ "id": "advanced-gis",
81
+ "title": "Advanced GIS Topics",
82
+ "source": "references/advanced-gis.md"
83
+ },
84
+ {
85
+ "id": "big-data",
86
+ "title": "Big Data and Cloud Computing",
87
+ "source": "references/big-data.md"
88
+ },
89
+ {
90
+ "id": "code-examples",
91
+ "title": "Code Examples",
92
+ "source": "references/code-examples.md"
93
+ },
94
+ {
95
+ "id": "coordinate-systems",
96
+ "title": "Coordinate Reference Systems (CRS)",
97
+ "source": "references/coordinate-systems.md"
98
+ },
99
+ {
100
+ "id": "core-libraries",
101
+ "title": "Core Geospatial Libraries",
102
+ "source": "references/core-libraries.md"
103
+ },
104
+ {
105
+ "id": "data-sources",
106
+ "title": "Geospatial Data Sources",
107
+ "source": "references/data-sources.md"
108
+ },
109
+ {
110
+ "id": "gis-software",
111
+ "title": "GIS Software Integration",
112
+ "source": "references/gis-software.md"
113
+ },
114
+ {
115
+ "id": "industry-applications",
116
+ "title": "Industry Applications",
117
+ "source": "references/industry-applications.md"
118
+ },
119
+ {
120
+ "id": "machine-learning",
121
+ "title": "Machine Learning for Geospatial Data",
122
+ "source": "references/machine-learning.md"
123
+ },
124
+ {
125
+ "id": "programming-languages",
126
+ "title": "Multi-Language Geospatial Programming",
127
+ "source": "references/programming-languages.md"
128
+ },
129
+ {
130
+ "id": "remote-sensing",
131
+ "title": "Remote Sensing Reference",
132
+ "source": "references/remote-sensing.md"
133
+ },
134
+ {
135
+ "id": "scientific-domains",
136
+ "title": "Scientific Domain Applications",
137
+ "source": "references/scientific-domains.md"
138
+ },
139
+ {
140
+ "id": "specialized-topics",
141
+ "title": "Specialized Topics",
142
+ "source": "references/specialized-topics.md"
143
+ },
144
+ {
145
+ "id": "troubleshooting",
146
+ "title": "GeoMaster Troubleshooting Guide",
147
+ "source": "references/troubleshooting.md"
148
+ }
149
+ ],
150
+ "checks": [
151
+ "crs.metric_operation",
152
+ "raster.nodata_declared",
153
+ "raster.resampling",
154
+ "rs.reflectance_range",
155
+ "rs.index_range"
156
+ ]
157
+ }