Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
R spatial data: sf vectors, terra rasters, spdep/spatialreg spatial stats, leaflet interactive maps, ggplot2+geom_sf() choropleths. CRS, spatial joins, geometry ops. Use when execution language is R. Python equivalent: geopandas.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
R geospatial analysis with sf (Simple Features for R), terra (modern raster operations), spdep/spatialreg (spatial statistics and spatial econometrics), leaflet (interactive web maps), and classInt (classification breaks for choropleth maps). Covers sf objects, CRS management, spatial joins, geometric operations, raster creation and manipulation, choropleth maps via ggplot2 + geom_sf(), interactive maps via leaflet, and spatial autocorrelation and regression. Use when the execution language is R and the task involves spatial data, map-making, or spatial statistics. Python equivalent: the geopandas skill.
sf (Simple Features) is the modern R package for vector geospatial data:
geometry list-column containing sfc geometries -- tabular data meets spatial operationsfilter(), mutate(), group_by(), summarize()), and the geometry column is preserved automaticallygeom_sf() plots sf objects with automatic CRS-aware axis labelsterra is the modern R package for raster data (replaces the retired raster package):
extract(), crop(), mask() using sf geometriesVersions installed in the DAAF container (R 4.5.3):
| Package | Version | Role |
|---|---|---|
| sf | 1.1-0 | Vector spatial data (Simple Features) |
| terra | 1.9-11 | Raster spatial data |
| stars | 0.7.2 | Spatiotemporal arrays (raster time series) |
| spdep | 1.4.2 | Spatial weights and spatial autocorrelation |
| spatialreg | 1.4.3 | Spatial regression models (SAR, SEM, SDM) |
| leaflet | 2.2.3 | Interactive web maps |
| classInt | 0.4.11 | Classification intervals for choropleth breaks |
sf 1.x changes to be aware of:
sf_use_s2(FALSE) to temporarily revert to planar GEOS operations when s2 produces unexpected results (see gotchas.md)st_make_valid() is now built into sf (no longer needs lwgeom)Four additional spatial packages are installed (versions verified) that map to
capabilities the geopandas skill documents on the Python side:
| Package | Version | Purpose | geopandas-skill equivalent |
|---|---|---|---|
| maptiles | 0.11.0 | Basemap tiles for static maps (get_tiles()) | contextily |
| exactextractr | 0.10.1 | Fast, exact zonal statistics of rasters over polygons (exact_extract()) | rasterstats zonal stats |
| osmdata | 0.3.0 | Download OpenStreetMap features via the Overpass API | osmnx / OSM download |
| tidygeocoder | 1.0.6 | Geocoding addresses to coordinates (geocode()) | geopy geocoding |
Honest asymmetry: point-pattern analysis (Ripley's K/G/F functions, spatial
point process models) requires spatstat, which is not installed — for
point-pattern methods, Python (PySAL pointpats via the geopandas skill) is
the routed path. Areal interpolation (tobler-style) also has no installed R
equivalent.
| File | Purpose | When to Read |
|---|---|---|
quickstart.md | sf objects, st_read/st_write, basic plotting, CRS inspection | Starting with sf or quick reminder |
crs.md | st_transform(), EPSG codes, CRS management, projection pitfalls | CRS errors or projection decisions |
spatial-ops.md | st_join(), st_buffer(), st_intersection(), st_union(), geometric operations | Combining or transforming spatial data |
raster.md | terra::rast(), raster arithmetic, extract(), crop/mask, raster-vector interaction | Working with raster data |
mapping.md | ggplot2 + geom_sf(), choropleth with scale_fill, classInt for breaks, annotation | Making static maps |
interactive.md | leaflet: addPolygons, addCircleMarkers, colorBin, popups, tile layers | Making interactive web maps |
spatial-stats.md | spdep::poly2nb(), nb2listw(), moran.test(), spatialreg::lagsarlm() | Spatial autocorrelation and regression |
gotchas.md | s2 geometry, CRS mismatch, geometry column persistence, large data performance | Debugging spatial issues |
quickstart.md then spatial-ops.mdmapping.md (relies on crs.md for projection choices)interactive.mdraster.mdspatial-stats.md (for methodology context, also load data-scientist skill's geospatial-analysis.md)gotchas.md first| Skill | Relationship |
|---|---|
geopandas | Python equivalent -- covers the same spatial domain for Python pipelines |
data-scientist (geospatial-analysis.md, geospatial-operations.md) | Spatial methodology -- when/why to use spatial methods, interpretation guidance |
ggplot2 | Visualization -- geom_sf() is built on ggplot2; load ggplot2 skill for themes and styling |
tidyverse | Data preparation -- sf objects work with dplyr verbs; tidyverse prepares data for spatial analysis |
r-stats | Statistical modeling -- non-spatial regression and diagnostics |
fixest | Fixed effects regression -- when combining spatial data with panel econometrics |
r-python-translation | Cross-language spatial translation |
Loading/saving spatial data?
+-- Read vector file (Shapefile, GeoPackage, GeoJSON) -> ./references/quickstart.md
+-- Read GeoParquet -> ./references/quickstart.md
+-- Create sf from lat/lon columns -> ./references/quickstart.md
+-- Write to file -> ./references/quickstart.md
+-- Read raster data (GeoTIFF) -> ./references/raster.md
+-- Raster time series (NetCDF) -> ./references/raster.md
Spatial operations?
+-- Join by location (point-in-polygon) -> ./references/spatial-ops.md
+-- Nearest-neighbor join -> ./references/spatial-ops.md
+-- Overlay (intersection, union, difference) -> ./references/spatial-ops.md
+-- Dissolve/aggregate polygons -> ./references/spatial-ops.md
+-- Buffer features -> ./references/spatial-ops.md
+-- Clip to boundary -> ./references/spatial-ops.md
+-- Compute distances -> ./references/spatial-ops.md
+-- Compute centroids or areas -> ./references/spatial-ops.md
CRS/projection issues?
+-- Check current CRS -> ./references/crs.md
+-- Reproject to different CRS -> ./references/crs.md
+-- Choose a projection for analysis -> ./references/crs.md
+-- Data has no CRS (set it) -> ./references/crs.md
+-- CRS mismatch error -> ./references/gotchas.md
+-- Area/distance calculations wrong -> ./references/crs.md
Making maps?
+-- Quick static choropleth (ggplot2) -> ./references/mapping.md
+-- Classification schemes (quantiles, Jenks) -> ./references/mapping.md
+-- Layered map with multiple sf layers -> ./references/mapping.md
+-- Multi-panel maps -> ./references/mapping.md
+-- Interactive map (pan/zoom/hover) -> ./references/interactive.md
+-- Export to PNG/SVG/HTML -> ./references/mapping.md or ./references/interactive.md
Spatial statistics?
+-- Build spatial weights (contiguity, distance) -> ./references/spatial-stats.md
+-- Test for spatial autocorrelation (Moran's I) -> ./references/spatial-stats.md
+-- Local clusters / hot spots (LISA) -> ./references/spatial-stats.md
+-- Spatial regression (lag, error, Durbin) -> ./references/spatial-stats.md
+-- Methodology guidance (interpretation, MAUP) -> data-scientist skill: geospatial-analysis.md
Raster operations?
+-- Read GeoTIFF -> ./references/raster.md
+-- Raster arithmetic -> ./references/raster.md
+-- Extract raster values at points/polygons -> ./references/raster.md
+-- Crop/mask raster by polygon -> ./references/raster.md
+-- Raster-vector conversion -> ./references/raster.md
+-- Raster time series (stars) -> ./references/raster.md
Having issues?
+-- s2 geometry errors -> ./references/gotchas.md
+-- CRS mismatch errors -> ./references/gotchas.md
+-- Geometry column lost after dplyr -> ./references/gotchas.md
+-- Invalid geometry errors -> ./references/gotchas.md
+-- Memory issues with large files -> ./references/gotchas.md
+-- General troubleshooting -> ./references/gotchas.md
In DAAF research pipelines, R spatial operations follow the file-first execution
protocol -- code is written to .R script files and executed via the
run_with_capture.sh wrapper, never run interactively.
The pattern:
scripts/stage{N}_{type}/{step}_{task-name}.Rbash {BASE_DIR}/scripts/run_with_capture.sh {PROJECT_DIR}/scripts/{script_name}.Rrun_with_capture.sh detects the .R extension and uses Rscript automatically_a.R, _b.R, etc.) for fixesRead agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the complete protocol.
R spatial script structure follows DAAF conventions:
# --- Config ---
library(sf)
library(dplyr)
library(ggplot2)
PROJECT_DIR <- "/daaf/research/YYYY-MM-DD_Project"
TARGET_CRS <- 5070 # NAD83 Conus Albers
# --- Load ---
# INTENT: Load school point data and county boundaries
schools <- st_read(file.path(PROJECT_DIR, "data", "schools.gpkg")) |>
st_transform(TARGET_CRS)
counties <- st_read(file.path(PROJECT_DIR, "data", "counties.gpkg")) |>
st_transform(TARGET_CRS)
cat("Schools:", nrow(schools), "rows\n")
cat("Counties:", nrow(counties), "rows\n")
# --- Transform ---
# INTENT: Assign each school to its county via spatial join
# ASSUMES: All schools fall within a county boundary
joined <- st_join(schools, counties["county_name"], join = st_within)
# --- Validate ---
stopifnot(nrow(joined) == nrow(schools))
stopifnot(sum(is.na(joined$county_name)) == 0)
cat("Join complete:", nrow(joined), "schools matched\n")
# --- Save ---
st_write(joined, file.path(PROJECT_DIR, "data", "schools_with_county.gpkg"),
delete_dsn = TRUE)
cat("Saved: schools_with_county.gpkg\n")
library(sf) # vector spatial data
library(terra) # raster spatial data
library(dplyr) # data manipulation (works with sf)
library(ggplot2) # static maps via geom_sf()
library(spdep) # spatial weights, Moran's I
library(spatialreg) # spatial regression models
library(leaflet) # interactive web maps
library(classInt) # classification intervals
| Operation | Code | Package |
|---|---|---|
| Read vector | st_read("data.gpkg") | sf |
| Read parquet (WKB geometry) | arrow::read_parquet() + st_as_sfc(structure(as.list(col), class = "WKB"), crs = ...) — sfarrow NOT installed; see quickstart.md | sf + arrow |
| From lat/lon | st_as_sf(df, coords = c("lon", "lat"), crs = 4326) | sf |
| Check CRS | st_crs(x) | sf |
| Reproject | st_transform(x, crs = 5070) | sf |
| Spatial join | st_join(points, polygons, join = st_within) | sf |
| Intersection | st_intersection(x, y) | sf |
| Buffer | st_buffer(x, dist = 1000) (CRS units) | sf |
| Centroid | st_centroid(x) | sf |
| Area | st_area(x) (returns units) | sf |
| Distance | st_distance(x, y) | sf |
| Union/dissolve | `x | > group_by(col) |
| Plot (static) | ggplot(x) + geom_sf(aes(fill = col)) | ggplot2 |
| Plot (interactive) | `leaflet(x) | > addTiles() |
| Write vector | st_write(x, "out.gpkg") | sf |
| Read raster | rast("elev.tif") | terra |
| Raster extract | extract(r, vect(sf_obj)) | terra |
| Crop raster | crop(r, vect(sf_obj)) | terra |
| EPSG | Name | Use For |
|---|---|---|
| 4326 | WGS84 | Storage, exchange, web (not analysis) |
| 5070 | NAD83 Conus Albers | US thematic maps (equal-area) |
| 3857 | Web Mercator | Web tiles display only |
| 32617 | UTM Zone 17N | US East Coast local analysis |
| Topic | Reference File |
|---|---|
| sf objects and structure | ./references/quickstart.md |
| st_read / st_write | ./references/quickstart.md |
| Creating sf from coordinates | ./references/quickstart.md |
| Basic plotting with plot() | ./references/quickstart.md |
| GeoParquet I/O | ./references/quickstart.md |
| CRS fundamentals | ./references/crs.md |
| st_transform / reprojection | ./references/crs.md |
| Choosing projections | ./references/crs.md |
| Common US projections | ./references/crs.md |
| set_crs vs st_transform | ./references/crs.md |
| Spatial joins (st_join) | ./references/spatial-ops.md |
| Nearest-neighbor joins | ./references/spatial-ops.md |
| Overlay (st_intersection, st_union) | ./references/spatial-ops.md |
| Dissolve and aggregation | ./references/spatial-ops.md |
| Buffering (st_buffer) | ./references/spatial-ops.md |
| Clipping (st_crop, st_intersection) | ./references/spatial-ops.md |
| Area, distance, centroid | ./references/spatial-ops.md |
| terra::rast() basics | ./references/raster.md |
| Raster arithmetic | ./references/raster.md |
| extract(), crop(), mask() | ./references/raster.md |
| stars spatiotemporal arrays | ./references/raster.md |
| Raster-vector conversion | ./references/raster.md |
| ggplot2 + geom_sf() maps | ./references/mapping.md |
| Choropleth maps | ./references/mapping.md |
| classInt classification schemes | ./references/mapping.md |
| Map annotation and styling | ./references/mapping.md |
| Multi-panel maps | ./references/mapping.md |
| leaflet interactive maps | ./references/interactive.md |
| addPolygons, addCircleMarkers | ./references/interactive.md |
| Color palettes and legends | ./references/interactive.md |
| Popups and labels | ./references/interactive.md |
| Tile providers | ./references/interactive.md |
| Spatial weights (nb, listw) | ./references/spatial-stats.md |
| Moran's I test | ./references/spatial-stats.md |
| LISA local indicators | ./references/spatial-stats.md |
| Spatial regression (SAR, SEM) | ./references/spatial-stats.md |
| s2 geometry engine | ./references/gotchas.md |
| CRS mismatch errors | ./references/gotchas.md |
| Invalid geometries | ./references/gotchas.md |
| Geometry column persistence | ./references/gotchas.md |
| Memory and performance | ./references/gotchas.md |
| sp/rgdal/rgeos migration | ./references/gotchas.md |
When sf is used as a primary analytical tool, include in the report's Software & Tools references:
Pebesma, E. (2018). "Simple Features for R: Standardized Support for Spatial Vector Data." The R Journal, 10(1), 439-446. https://doi.org/10.32614/RJ-2018-009
Cite when: sf is used for spatial operations, spatial joins, or map production central to the analysis. Do not cite when: Only used to read a shapefile for a simple reference lookup.
If terra raster operations are also used, additionally cite:
Hijmans, R.J. (2024). terra: Spatial Data Analysis. R package. https://rspatial.org/
If spdep/spatialreg spatial analysis is also used, additionally cite:
Bivand, R.S., Pebesma, E., and Gomez-Rubio, V. (2013). Applied Spatial Data Analysis with R (2nd ed.). Springer. https://doi.org/10.1007/978-1-4614-7618-4
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.
中文简介正在准备中。当前显示原文说明。
In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).
中文简介正在准备中。当前显示原文说明。
Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.
中文简介正在准备中。当前显示原文说明。
Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.
中文简介正在准备中。当前显示原文说明。
Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.
中文简介正在准备中。当前显示原文说明。