Builds territory planning workflows in CARTO, combining territory balancing (dividing areas into balanced regions) and location allocation (finding optimal facility locations).
Ships in carto-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Builds CARTO Workflows that solve two related spatial optimization problems: dividing areas into balanced territories (e.g. sales regions, service zones) and finding optimal facility locations that maximize coverage or minimize cost.
Prerequisites: Load carto-create-workflow for the development process, JSON structure, and validation. It covers both access paths — the MCP server's workflow tools (create_workflow, validate_workflow, run_workflow) when attached, the carto workflows CLI otherwise. Routing signals: carto-basics/references/access-paths.md. Both components require the Territory Planning Extension Package installed on the connection. Territory Balancing exists only on BigQuery; Location Allocation on BigQuery (prefix territoryplanning.) and Snowflake (prefix territoryplanning-sf.). Check with carto workflows components list --connection <conn> --search territory --json (MCP: read_workflow_components method=list) and read inputs and outputs with components get; if nothing comes back, the package is not installed on that connection. On other providers the closest native option for territories is native.clusterkmeans (proximity clusters in a cluster column, without demand balancing; BigQuery, Snowflake, Redshift, PostgreSQL).
Divides a study area into spatially contiguous territories that are balanced by a demand variable (e.g. workload, population, revenue). BigQuery only.
Source Data (points) -> Spatial Indexing -> Aggregate per Cell -> Territory Balancing -> Save
Use native.gettablebyname. Input is typically point data with one or more numeric metrics to balance.
Success: Node outputs a table with a geometry column and numeric metric columns.
Use native.h3frompoint (or native.quadbinfrompoint) to assign each point to a grid cell.
Resolution guidance: Higher resolution = smaller cells = finer-grained territories, but more computation. H3 resolution 8-9 is typical for city-level analysis.
Success: Output has a spatial index column (e.g. h3).
Use native.groupby to produce one row per cell with the metrics to balance:
h3)geom,count,revenue,sum,population,avgUse a count or sum as the demand column (it must add up across cells); averages and ratios only work as similarity features.
Success: One row per cell with numeric columns for demand and optional similarity features.
Use territoryplanning.territorybalancing (BigQuery only) with:
| Input | Description | Example |
|---|---|---|
input_table | Table input; the edge's target handle is input_table | |
index_column | H3 or Quadbin column | h3 |
demand_column | Numeric column to balance across territories | geom_count |
similarity_feats | Optional numeric columns for within-territory similarity | ["sentiment_avg", "popularity_avg"] |
npartitions | Number of territories to create | 9 |
keep_input_columns | Include all input columns in output | true |
Success: The output (source handle output_table, not result) has the index column, a cluster column with the territory ID, and the input columns when keep_input_columns is true. Each cell is assigned to exactly one territory.
Use native.saveastable to persist results. The spatial index column is directly visualizable in CARTO Builder, colored by cluster.
Success: Validated workflow uploadable via create_workflow (MCP) or carto workflows create (CLI).
Finds the subset of candidate facilities that minimizes total cost, minimizes the maximum cost, or maximizes demand coverage, and assigns each demand point to an open facility. BigQuery and Snowflake only; names below use the BigQuery prefix (territoryplanning-sf. on Snowflake).
Demand -> Demand Points Preparation ------------------┐
Candidates -> Facilities Preparation -----------------┤
Candidate x demand costs -> Cost Matrix Preparation --┼-> Location-Allocation -> Save
(optional) Constraints Definition --------------------┘
Every preparation node emits on source handle output_table.
Load demand with native.gettablebyname (e.g. population per H3 cell, customer locations), then add territoryplanning.demandpoints (target handle dpoints_table): dpoints_id = unique id, dpoints_geom = point geometry, demand_bool: true and demand_col = the demand value. For an H3 grid, first add a point per cell with native.h3center (h3col: h3, new column h3_geom) and use h3 as the id.
Success: Output output_table with dpoint_id, geom, demand.
Load candidates with a second native.gettablebyname. If candidates need filtering, use native.wheresimplified or native.limit -- fewer candidates = faster computation. Then add territoryplanning.facilities (target handle candidates_table): candidates_id = unique id, candidates_geom = point geometry. Existing sites that must stay open go in required_table with required_bool: true; competitors in competitors_table with competitors_bool: true. Ids must be unique across candidate, required and competitor facilities.
Success: Output output_table with facility_id, geom, facility_type.
Location-Allocation needs one row per candidate and demand point with a cost:
native.createroutingmatrix (origins = candidates, destinations = demand points). It returns route_duration in seconds and route_distance in meters, prefixes the input columns with origin_ / destination_, and consumes LDS quota for every pair.native.crossjoin (candidates as maintable, demand as secondarytable; secondary columns get the suffix _joined, or every column gets an l_ / r_ prefix on Databricks cluster connections), then native.selectexpression with ST_DISTANCE(<candidate geom>, <demand geom>_joined) (meters for geography columns).Then add territoryplanning.costs (target handle costs_table): facilities_column, dpoints_column, cost_column. The ids must be the same ones given to the two preparation nodes.
Success: Output output_table with facility_id, dpoint_id, cost.
Use territoryplanning.locationallocation with:
| Input | Description | Example |
|---|---|---|
facilities_table | Output of Facilities Preparation (edge from its output_table) | |
dpoints_table | Output of Demand Points Preparation | |
costs_table | Output of Cost Matrix Preparation | |
optimization_strategy | Minimize total cost, Minimize maximum cost or Maximize coverage | Maximize coverage |
demand_bool | true to use the demand set in Demand Points Preparation | true |
limit_facilities_bool + max_facilities | Maximum number of facilities to open (an upper bound) | true, 5 |
Read the other options (required and competitor facilities, budget, groups, time_limit) with components get.
Success: Two outputs. output_table (source handle output_table) has one row per assignment: facility_id, dpoint_id, demand, geom. metrics_table has objective_value, gap, solving_time, termination_reason.
Set optimization_strategy: "Maximize coverage" and coverage_radius: the maximum cost a facility can cover, in the cost matrix's units (e.g. 900 for 15 min when the cost is route_duration in seconds). The default is 10.
Use the same node with optimization_strategy: "Minimize total cost" (or "Minimize maximum cost" to minimize the worst assignment). The cost is whatever the cost matrix holds. Minimum usage, capacities and required/forbidden assignments only apply to these two strategies.
Use native.saveastable on output_table (and on metrics_table if the user wants the solver metrics).
Success: Validated workflow uploadable via create_workflow (MCP) or carto workflows create (CLI).
h3, geom_count, facility_id, dpoint_id, route_duration, etc.) — BigQuery convention. On Snowflake (Location Allocation only), unquoted identifiers surface UPPERCASE — reference them as FACILITY_ID, DPOINT_ID, ROUTE_DURATION. See carto-create-workflow/references/providers/<provider>.md for casing rules and SQL dialect equivalents.time_limit (seconds, default 3600, max 7200) or once within relative_gap (%), and reports gap and termination_reason in metrics_table; check them before calling a result optimal.route_duration, meters for route_distance or a straight-line distance). The same applies to the competitor cost threshold.native.: territoryplanning.territorybalancing (BigQuery only), and territoryplanning.facilities, .demandpoints, .costs, .constraints, .locationallocation; on Snowflake the prefix is territoryplanning-sf.. Extension outputs are named output_table (and metrics_table), not result.| Variant | How |
|---|---|
| Sales territory balancing | Points -> H3 -> aggregate revenue per cell -> territory balancing with revenue as demand |
| Service zone design | Grid with population -> territory balancing to create equal-population zones |
| Warehouse/depot placement | Population grid as demand + existing warehouses as candidates -> minimize total cost |
| Emergency response hubs | Population grid as demand + candidate sites -> maximize coverage with a response-time radius |
| Retail network expansion | Customer density grid as demand + potential store locations -> maximize coverage |
| Hub placement and service areas | Location allocation picks the hubs and already assigns each demand point to one (facility_id per dpoint_id); territory balancing cannot be anchored to given hubs |
What SKILL.md sets; muted values are Claude Code's defaults
/carto-skills:carto-territory-planningfrom carto-skills
npx claudepluginhub cartodb/agent-skills --plugin carto-skills24 skills in this plugin
/carto-arcgis-migrationEnd-to-end ArcGIS Portal / AGOL → CARTO migration. Triggers when the user wants to migrate ArcGIS content to CARTO, plan a migration, asks "what's in my Portal", names a Portal/AGOL URL, or asks to migrate the datasets / web maps / simple apps. Runs three phases — discover (enumerate items + write MIGRATION_MANIFEST.md), migrate-data (Hosted Feature Layers / Tables → CARTO tables), migrate-maps (Web Maps + simple Dashboards / Web Experiences / Web Mapping Apps → CARTO Builder maps). Default mode is batch; migrated maps are always tagged `From ArcGIS` and created as private./carto-basicsStart here for first-time CARTO use. Orients on the two parallel access paths into the CARTO platform — the MCP server (the primary path for inline, in-conversation work in chat hosts, including creating and editing maps and Workflows) and the CLI (for scripting, CI/CD, headless and bulk/cross-org work, and deeper administration and auditing such as usage-log queries) — and which skills cover each. Also covers CLI install, authentication, profiles, JSON output, and async job patterns.Other plugins' skills for the same job
/carto-composite-scoringGuides the user through building composite score workflows when they ask about composite scores, indexes, multi-variable scores, ranking areas, site scoring, market potential, resilience indexes, risk indexes, weighted scores, PCA, or supervised/unsupervised scoring.