AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Carto Spatial Autocorrelation

skill-cartodb-agent-skills-carto-spatial-autocorrelation · by CartoDB

Builds Moran's I spatial autocorrelation workflows in CARTO. Triggers when the user mentions spatial autocorrelation, Moran's I, spatial dependency, spatial correlation, spatial outliers, HH HL LH LL quadrants, high-high clusters, low-low clusters, spatial weight matrix, "is there clustering", "are values spatially correlated", local indicators of spatial association, LISA, spatial randomness tes…

No reviews yet
0 installs
33 views
0.0% view→install

Install

$ agentstack add skill-cartodb-agent-skills-carto-spatial-autocorrelation

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-cartodb-agent-skills-carto-spatial-autocorrelation)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Carto Spatial Autocorrelation? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Spatial Autocorrelation with Moran's I

Builds CARTO Workflows that measure spatial autocorrelation using Moran's I, determining whether a variable exhibits clustering, dispersion, or randomness, and classifying each location into HH/HL/LH/LL quadrants.

Prerequisites: Load carto-create-workflow for the development process, JSON structure, and validation commands.

When to use Moran's I vs Getis-Ord Gi*:

  • Moran's I: "Is there clustering?" + classify into cluster types (HH, HL, LH, LL) + identify spatial outliers (HL, LH)
  • Getis-Ord Gi*: "Where are the hotspots/coldspots?" + magnitude of clustering (z-scores)

Instructions

A Moran's I workflow follows this pipeline:

Source Data -> (Filter) -> Spatial Indexing (H3) -> Aggregation -> Moran's I -> (Filter Significant) -> Save

Step 1: Load Source Data

Use native.gettablebyname. The input table typically contains point geometries or pre-indexed grid data.

Success: Node outputs a table with a geometry column (e.g. geom) or an existing spatial index column.

Step 2: Filter (if needed)

Use native.wheresimplified or native.where to narrow the dataset (e.g. filter by category, date range, non-null values).

Success: Output contains only the subset relevant to the analysis.

Step 3: Spatial Indexing

Convert point geometries to H3 cells using native.h3frompoint.

Resolution guidance -- higher resolution = smaller cells = more local patterns:

| Resolution | Cell size | Use case | |------------|-----------|----------| | H3 res 7 | ~5 km edge | District/city-level patterns | | H3 res 8 | ~2 km edge | Neighborhood-level | | H3 res 9 | ~500m edge | Street-level (used in Berlin POI tutorial) |

Success: Every row has a spatial index column (e.g. h3).

Step 4: Aggregate per Cell

Use native.groupby to produce one row per cell with a numeric value:

  • Group by: the spatial index column (h3)
  • Aggregation: geoid,count (or value_col,sum / value_col,avg)

Success: Output has exactly one row per unique cell with a numeric column (e.g. geoid_count).

Step 5: Run Moran's I

Use native.moransi with:

| Input | Description | Default | |-------|-------------|---------| | indexcol | Column with H3/Quadbin indexes | h3 | | valuecol | Numeric column to test for autocorrelation | geoid_count | | size | K-ring neighborhood radius (in hops) | 3 | | decay | Distance decay function for spatial weights | uniform |

Decay options: uniform, inverse, inverse_square, exponential.

  • uniform: Equal weight to all neighbors within the k-ring
  • exponential: Weight decreases exponentially with distance (used in Berlin POI tutorial)

K-ring size: Larger = broader neighborhood = smoother global patterns. Smaller = more localized assessment. The choice of neighborhood size significantly affects results.

Success: Output contains index, morans_i, p_value, and quadrant columns for every cell. (See the Provider casing note in Gotchas — Snowflake surfaces these UPPERCASE.)

Step 6: Filter Significant Results (recommended)

Use native.where to keep only statistically significant cells. Quadrant classification is only meaningful for significant cells.

Common filters:

  • `p_value 0 = spatial clustering (similar values near each other)
  • .md` for casing rules and SQL dialect equivalents.
  • The Moran's I component requires the Analytics Toolbox. Always run carto workflows verify-remote --connection to ensure the AT path is resolved. carto workflows validate is offline and cannot resolve AT location.
  • The output column is named index, not h3 or quadbin. If you need to join back to original data, rename it (e.g. with native.renamecolumn). This is the same behavior as Getis-Ord.
  • The valuecol must be numeric. If you are counting features, the group-by step must produce a count column -- do not pass the raw index column as the value.
  • Resolution too high + large area = very many cells, which can be slow or hit memory limits. Start with a moderate resolution and refine.
  • Moran's I is sensitive to the definition of neighborhood. Both k-ring size and decay function choice materially affect results. Document your choices and consider testing alternatives.
  • Quadrant classification is only meaningful for statistically significant cells. Always filter by p_value before interpreting quadrants -- non-significant cells may show any quadrant label by chance.
  • The decay input parameter is named decay (not kernel). Check the component schema if unsure.

Reference Templates

| Resource | Description | |----------|-------------| | BQ Tutorial | Computing spatial autocorrelation of POI locations in Berlin (BigQuery) | | SF Tutorial | Same tutorial for Snowflake | | Workflow template | "Computing the spatial auto-correlation of point of interest locations" (available in CARTO Workspace) |


Common Variations

| Variant | How | |---------|-----| | Pre-indexed data | Skip Step 3 if data already has H3/Quadbin column | | Polygon input instead of points | Use native.h3polyfill instead of native.h3frompoint | | Complete grid (no gaps) | Polyfill study area boundary first, then enrich with data (same approach as hotspot analysis) | | Combine with Getis-Ord | Run both analyses on the same aggregated grid, then join results for a richer picture | | Filter to outliers only | Keep HL and LH quadrants to find anomalous locations |

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.