carto-trade-area-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTrade Area Analysis
商圈分析
Builds CARTO Workflows that define catchment areas around candidate locations, enrich them with data, and score/rank locations for site selection, billboard placement, or coverage analysis.
Prerequisites: Load for the development process, JSON structure, and validation commands.
carto-create-workflow构建CARTO工作流,用于定义候选地点周边的客群覆盖区域,为其补充数据,并针对选址、广告牌投放或覆盖分析对地点进行评分/排名。
前提条件:加载以获取开发流程、JSON结构和验证命令。
carto-create-workflowInstructions
操作步骤
A trade area workflow always follows this pipeline:
Candidate Locations → (Filter) → Catchment Areas → Spatial Index → Enrich → Aggregate → Score/Rank → Save商圈分析工作流始终遵循以下流程:
候选地点 → (过滤) → 客群覆盖区域 → 空间索引 → 数据补充 → 聚合 → 评分/排名 → 保存Step 1: Load Candidate Locations
步骤1:加载候选地点
Use to load stores, billboards, POIs, or any point dataset representing candidate locations.
native.gettablebynameSuccess: Node outputs a table with a geometry column (e.g. ) and a unique location identifier.
geom使用加载门店、广告牌、POI或任何代表候选地点的点数据集。
native.gettablebyname成功标志:节点输出包含几何列(如)和唯一地点标识符的表格。
geomStep 2: Filter/Limit Candidates (optional)
步骤2:过滤/筛选候选地点(可选)
Use to narrow candidates (e.g. specific city, category). Use + for top-N by a metric (e.g. top 50 by revenue).
native.wheresimplifiednative.orderbynative.limitSuccess: Output contains only the candidate subset relevant to the analysis. Reducing candidates early prevents combinatorial explosion downstream.
使用缩小候选范围(如特定城市、类别)。使用 + 筛选按指标排名的前N个候选(如按收入排名前50)。
native.wheresimplifiednative.orderbynative.limit成功标志:输出仅包含与分析相关的候选子集。尽早筛选候选可避免后续流程出现组合爆炸问题。
Step 3: Generate Catchment Areas
步骤3:生成客群覆盖区域
Choose the catchment method based on the use case:
| Method | Component | When to use | Key params |
|---|---|---|---|
| Isochrones | | Site selection, retail — realistic road-network areas | |
| Buffers | | Billboard coverage, proximity — simple geometric circles | |
Isochrones vs Buffers: Isochrones follow the road network and produce realistic catchment shapes but require a CARTO LDS API call. Buffers are purely geometric circles — simpler and faster, suitable for proximity analysis or billboard coverage.
Success: Each candidate location has an associated polygon representing its catchment area.
根据使用场景选择合适的覆盖区域生成方法:
| 方法 | 组件 | 适用场景 | 关键参数 |
|---|---|---|---|
| 等时线(Isochrones) | | 选址、零售——贴合实际路网的区域 | |
| 缓冲区(Buffers) | | 广告牌覆盖、邻近分析——简单几何圆形 | |
等时线 vs 缓冲区:等时线遵循路网,生成贴合实际的覆盖区域形状,但需要调用CARTO LDS API。缓冲区为纯几何圆形——更简单快速,适用于邻近分析或广告牌覆盖分析。
成功标志:每个候选地点都有对应的多边形代表其客群覆盖区域。
Step 4: Convert Catchment to Spatial Index
步骤4:将覆盖区域转换为空间索引
Use or to tessellate catchment polygons into grid cells. The resolution must match the enrichment dataset you plan to use.
native.h3polyfillnative.quadbinpolyfillSuccess: Output contains one row per grid cell per location, with both the spatial index column and the location identifier preserved.
使用或将覆盖多边形细分为网格单元。分辨率必须与计划使用的补充数据集匹配。
native.h3polyfillnative.quadbinpolyfill成功标志:输出包含每个地点对应的每个网格单元的行,同时保留空间索引列和地点标识符。
Step 5: Enrich with Data
步骤5:补充数据
Join grid cells with a spatial features dataset or use :
native.h3enrich- JOIN approach: or
native.joinv2with a pre-indexed enrichment tablenative.spatialjoin - Enrich approach: to pull variables from CARTO's Data Observatory
native.h3enrich
Success: Each grid cell row has enrichment variables (e.g. population, income, foot traffic) attached.
将网格单元与空间特征数据集关联,或使用:
native.h3enrich- 关联方式:使用或
native.joinv2与预索引的补充表格关联native.spatialjoin - 补充方式:使用从CARTO数据观测站提取变量
native.h3enrich
成功标志:每个网格单元行都附加了补充变量(如人口、收入、人流量)。
Step 6: Aggregate Back to Locations
步骤6:聚合回地点维度
Use to collapse grid-cell rows back to one row per location:
native.groupby- Group by: the location identifier column
- Aggregation: (comma-separated column,method pairs)
population,sum,income,avg
Success: Output has one row per candidate location with aggregated enrichment metrics.
使用将网格单元行合并为每个地点一行:
native.groupby- 分组依据:地点标识符列
- 聚合规则:(逗号分隔的列名与方法对)
population,sum,income,avg
成功标志:输出每个候选地点一行,包含聚合后的补充指标。
Step 7: Score and Rank
步骤7:评分与排名
Three-part scoring pattern:
- Normalize each variable to [0,1] using (one call per variable, or chain multiple)
native.normalize - Composite score via : weighted addition of normalized variables, e.g.
native.selectexpressionnormalized_population * 0.4 + normalized_income * 0.3 + normalized_traffic * 0.3 - Rank using (descending by composite score) +
native.orderby(top N)native.limit
Success: Output is a ranked list of candidate locations with a composite score and the contributing normalized variables.
三步评分模式:
- 标准化:使用将每个变量标准化至[0,1](每个变量调用一次,或链式调用多个)
native.normalize - 综合评分:通过计算加权和,例如
native.selectexpressionnormalized_population * 0.4 + normalized_income * 0.3 + normalized_traffic * 0.3 - 排名:使用(按综合评分降序) +
native.orderby(取前N个)native.limit
成功标志:输出按综合评分排序的候选地点列表,包含综合评分及各标准化变量。
Step 8: Save
步骤8:保存
Use to persist the ranked results.
native.saveastableSuccess: Validated workflow that can be uploaded via .
carto workflows create使用保存排名结果。
native.saveastable成功标志:验证通过的工作流可通过上传。
carto workflows createGotchas
注意事项
- Provider casing & SQL dialect. This skill uses lowercase column names (,
geom,population,income, etc.) — BigQuery / Databricks / Postgres / Redshift convention. On Snowflake, unquoted identifiers surface UPPERCASE — reference them asnormalized_population,GEOM,POPULATION,INCOME. SeeNORMALIZED_POPULATIONfor casing rules and SQL dialect equivalents.carto-create-workflow/references/providers/<provider>.md - Isochrone and route components call CARTO's LDS API — they require a valid connection with API access enabled. Buffers do not.
- Cross Join for distance matrices can explode with many locations x many grid cells. Filter and limit candidates first (Step 2) to keep the pipeline manageable.
- H3 resolution must match the enrichment dataset resolution. Check the enrichment table's index column before choosing resolution.
- Buffer distance is in meters. Isoline range is in seconds (for ) or meters (for
type=time).type=distance - The component expects
native.commercialhotspotsas a Python-style list string (variablecolumns) and['col1', 'col2']as comma-separated values — inconsistent with other components.weights - When aggregating enrichment back to locations (Step 6), ensure the GROUP BY uses the location identifier, not the grid cell index. Grouping by the grid cell produces per-cell results instead of per-location.
- When using for competitor proximity, the output is grid-based. Join it back to the location table to get per-location distance metrics.
native.h3distance
- 提供商大小写与SQL方言:本技能使用小写列名(、
geom、population、income等)——符合BigQuery / Databricks / Postgres / Redshift的约定。在Snowflake中,未加引号的标识符会显示为大写——需引用为normalized_population、GEOM、POPULATION、INCOME。请查看NORMALIZED_POPULATION获取大小写规则和SQL方言对应关系。carto-create-workflow/references/providers/<provider>.md - 等时线和路线组件会调用CARTO的LDS API——需要启用API访问权限的有效连接。缓冲区无需调用该API。
- 距离矩阵的交叉连接会因大量地点×大量网格单元而导致数据爆炸。请先筛选候选地点(步骤2)以保持流程可控。
- H3分辨率必须与补充数据集的分辨率匹配。选择分辨率前请检查补充表格的索引列。
- 缓冲区距离单位为米。等时线范围单位为秒(当时)或米(当
type=time时)。type=distance - 组件要求
native.commercialhotspots为Python风格的列表字符串(variablecolumns),['col1', 'col2']为逗号分隔值——与其他组件的格式不一致。weights - 在将补充数据聚合回地点维度时(步骤6),确保分组依据为地点标识符,而非网格单元索引。按网格单元分组会得到每个单元的结果,而非每个地点的结果。
- 使用分析竞品邻近度时,输出为网格维度。需将其关联回地点表格以获取每个地点的距离指标。
native.h3distance
Reference Templates
参考模板
These files are working examples in this skill directory:
| File | Description |
|---|---|
| Retail stores in Boston — 5-min walk-time isochrones via LDS API |
| Billboard site scoring — buffer, enrich, normalize, weighted composite score, top-N |
| Commercial hotspot detection — H3 distance to competitors, weighted hotspot analysis |
本技能目录中的以下文件为可运行示例:
| 文件 | 描述 |
|---|---|
| 波士顿零售门店——通过LDS API生成5分钟步行等时线 |
| 广告牌场地评分——缓冲区、数据补充、标准化、加权综合评分、取前N个 |
| 商业热点检测——使用H3距离分析竞品邻近度、加权热点分析 |
Common Variations
常见变体
| Variant | How |
|---|---|
| Retail site selection | Isochrones (walk/drive) -> H3 polyfill -> enrich with demographics -> score by population + income |
| Billboard/OOH placement | Buffers -> H3 polyfill -> enrich with audience/traffic -> normalize + weighted score -> top-N |
| Commercial hotspot detection | H3 grid -> |
| Drive-time coverage analysis | Isochrones (car, multiple ranges) -> union -> dissolve to find total coverage area |
| Walk-time catchment comparison | Isochrones (walk, 5/10/15 min) -> enrich each band -> compare population captured per band |
| Franchise territory planning | Isochrones per candidate -> check overlap -> filter non-overlapping set -> score remaining |
| 变体 | 实现方式 |
|---|---|
| 零售选址 | 等时线(步行/驾车)-> H3多边形填充 -> 补充人口统计数据 -> 按人口+收入评分 |
| 广告牌/OOH投放 | 缓冲区 -> H3多边形填充 -> 补充受众/流量数据 -> 标准化+加权评分 -> 取前N个 |
| 商业热点检测 | H3网格 -> 使用 |
| 驾车时长覆盖分析 | 等时线(驾车,多范围)-> 合并 -> 融合以获取总覆盖区域 |
| 步行时长覆盖对比 | 等时线(步行,5/10/15分钟)-> 为每个时段补充数据 -> 对比各时段覆盖的人口 |
| 特许经营区域规划 | 为每个候选地点生成等时线 -> 检查重叠 -> 筛选非重叠集合 -> 对剩余地点评分 |