Agent Skill · Carto

carto-hotspot-analysis

Builds Getis-Ord Gi* hotspot analysis workflows in CARTO. Triggers when the user mentions hotspots, coldspots, spatial clusters, Getis-Ord, Gi*, cluster detection, concentration areas, "where do X cluster", spacetime hotspot, temporal clusters, time-varying patterns, hotspot trends, emerging hotspots, Mann-Kendall, or wants to find statistically significant spatial or spatiotemporal patterns in point or grid data.

Provider: Carto Path in repo: skills/carto-hotspot-analysis/SKILL.md

Skill body

Hotspot Analysis with Getis-Ord Gi*

Builds CARTO Workflows that identify statistically significant spatial clusters (hotspots and coldspots) using the Getis-Ord Gi* statistic.

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


Instructions

A hotspot workflow always follows this pipeline:

Source Data → (Filter) → Spatial Indexing → Aggregation → Getis-Ord Gi* → (Filter Significant) → Save

Step 1: Load Source Data

Use native.gettablebyname. The input table typically contains point geometries.

Success: Node outputs a table with a geometry column (e.g. geom).

Step 2: Filter (if needed)

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

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

Step 3: Build a Complete Grid

Preferred approach: First polyfill the study area boundary (e.g. district polygons) with native.h3polyfill to create a complete, gap-free grid. Then enrich this grid with the data to analyze (e.g. count points per cell via native.h3enrich or a manual join + group by). This ensures every cell in the study area has a value (even if 0), which Getis-Ord needs — gaps in the grid distort the neighborhood calculations and can produce misleading results.

Simpler alternative (when no study area boundary is available): Convert point geometries directly to grid cells with native.h3frompoint or native.quadbinfromgeopoint. Be aware this only produces cells where data exists, leaving gaps that may affect the statistic.

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

Success: A contiguous grid covering the study area, with every cell assigned 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:

If using the polyfill approach, cells with no data should have a value of 0 (use COALESCE(count, 0) via native.selectexpression after joining).

Success: Output has exactly one row per unique cell with a count/sum column — no gaps.

Step 5: Run Getis-Ord Gi*

Use native.getisord with:

Input Description Default
indexcol Column with H3/Quadbin indexes h3
valuecol Numeric column to analyze h3_count
kernel Weighting function for neighbors uniform
size K-ring size (neighborhood radius in hops) 3

Kernel options: uniform, triangular, quadratic, quartic, gaussian. Default to uniform (equal weight to all neighbors) unless the user has a reason to decay weight with distance.

K-ring size: Larger = smoother, broader patterns. Smaller = more localized clusters.

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

Step 6: Filter Significant Results (optional)

Use native.where to keep only statistically significant cells:

Success: Only cells with statistically meaningful clustering remain.

Step 7: Save

Use native.saveastable to persist results. The H3/Quadbin column is directly visualizable in CARTO Builder without geometry conversion.

Success: Validated workflow that can be uploaded via carto workflows create.


Output Columns

Column Meaning
index Spatial index cell ID (H3 or Quadbin)
gi Gi* z-score — positive = hotspot, negative = coldspot
p_value Statistical significance — lower = more confident

The engine declares these lowercase. See the Provider casing note in Gotchas for Snowflake.


Gotchas


Spacetime Variants

Getis-Ord Spacetime (native.getisordspacetime):

Spacetime Hotspot Classification (native.spacetimehotspotsclassification):

Time Series Clustering (native.timeseriesclustering):


Reference Templates

These files are working examples (skill-local files in hotspot-analysis/, others in the project root):

File Description
poi_hotspot.json Stockholm amenity POIs — H3 res 9, uniform kernel, k=3
space_time_hotspot.json Barcelona accidents — spacetime Gi*, H3 res 9, weekly bins
spacetime_hotspot_classification.json London collisions — spacetime Gi* + classification, gaussian kernel

Common Variations

Variant How
Polygon input instead of points Use native.h3polyfill instead of native.h3frompoint
Enrich existing grid Use native.h3enrich to count points into a grid (avoids manual group-by + join)
Combine with other data Join Getis-Ord output with enrichment or attribute tables before saving
Spacetime hotspots Use native.getisordspacetime — see Spacetime Variants section above
Classify hotspot trends Use native.spacetimehotspotsclassification — chains after spacetime Gi* output

Skill frontmatter

license: MIT

Work with this as data

Every skill here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for agent skills

4 MCP tools reach this
  • find_skillsBrowse and filter every skill in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This skill
curl "https://apis.io/api/v1/skills/carto-hotspot-analysis"
All agent skills
curl "https://apis.io/api/v1/skills?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.