Routing and Origin-Destination Analysis
Builds CARTO Workflows that compute routes, travel time/distance matrices, and isoline catchment areas. Supports driving and walking modes. Also covers OD flow pattern analysis using spatial indexing.
Prerequisites: Load
for the development process, JSON structure, and validation commands.
Instructions
Three main workflow patterns exist. Choose based on the use case:
| Pattern | Component | Use when |
|---|
| Isoline/Isochrone | | You need catchment polygons around locations (e.g. "everywhere reachable within 10 min") |
| OD Matrix | | You need travel time/distance between every origin-destination pair (analytics, no geometry) |
| Route Creation | | You need actual route line geometries between OD pairs (visualization, detailed path) |
Pattern A: Isoline/Isochrone Generation
Pipeline:
Source Points -> (Filter) -> Isolines -> (Polyfill / Enrich) -> Save
Step A1: Load Source Points
Use
to load locations (stores, stations, facilities).
Success: Table with a geometry column and a unique location identifier.
Step A2: Generate Isolines
| Input | Description | Example |
|---|
| Travel mode | or |
| What the range measures | or |
| Threshold value | Seconds for time (e.g. = 10 min), meters for distance (e.g. = 5 km) |
Success: Each input point has an associated polygon geometry representing the reachable area.
Step A3: Post-Processing (optional)
Common follow-ups after isoline generation:
- Polyfill + Enrich: Convert isoline polygons to H3 with , then enrich with demographics or POI data (see trade-area-analysis skill).
- Overlap analysis: Use to find which isolines overlap, identifying areas served by multiple locations.
- Coverage union: Use to merge all isoline polygons into a single coverage footprint.
Step A4: Save
Use
to persist isoline polygons or enriched results.
Success: Validated workflow uploadable via
.
Pattern B: OD Matrix (Travel Time/Distance)
Pipeline:
Origins Table -> ┐
├-> OD Matrix -> (Filter/Aggregate) -> Save
Destinations Table -> ┘
Step B1: Load Origins and Destinations
Use two
nodes -- one for origins, one for destinations. Both need geometry columns.
Success: Two tables, each with point geometries and unique identifiers.
Step B2: Compute OD Matrix
| Input | Description |
|---|
| or |
| Origins input | Connected from the origins table node |
| Destinations input | Connected from the destinations table node |
Success: One row per origin-destination pair with travel time and distance.
Step B3: Filter or Aggregate (optional)
Common post-processing:
- Nearest destination: Use to find the minimum per origin, then join back to get the nearest destination.
- Threshold filter: Use to keep only pairs within a time/distance limit (e.g. for 30-min threshold).
- Accessibility score: Count destinations reachable within a threshold per origin using .
Step B4: Save
Success: Validated workflow uploadable via
.
Pattern C: Route Geometries
Pipeline:
Origins Table -> ┐
├-> Routes -> Save
Destinations Table -> ┘
Step C1: Load Origins and Destinations
Same as Pattern B -- two
nodes with point geometries.
Step C2: Compute Routes
| Input | Description |
|---|
| or |
| Origins input | Connected from the origins table node |
| Destinations input | Connected from the destinations table node |
Output: Route line geometries with
and
attributes.
Success: One route geometry per OD pair, visualizable on a map.
Step C3: Save
Success: Validated workflow uploadable via
.
Pattern D: OD Flow Analysis (Grid-Based)
For analyzing trip/movement patterns at scale (e.g. taxi trips, bike rides, commute flows) without calling routing APIs.
Pipeline:
Trip Data -> H3 (origin) + H3 (destination) -> Group By (origin_h3, dest_h3) -> Save
Step D1: Load Trip Data
Use
. The table should have both origin and destination coordinates (e.g. pickup_lon/lat, dropoff_lon/lat).
Step D2: Index Origins and Destinations to H3
Use
to compute H3 cells for both origin and destination points:
- Origin H3: derive from pickup coordinates
- Destination H3: derive from dropoff coordinates
Alternatively, if the data has separate geometry columns, use
for each.
Step D3: Aggregate Flows
Use
to count trips per (origin_h3, destination_h3) pair:
- Group by:
origin_h3, destination_h3
- Aggregation: (trip count per OD pair)
Success: One row per unique OD cell pair with trip count -- ready for flow visualization.
Step D4: Save
Gotchas
- Provider casing & SQL dialect. This skill uses lowercase column names (, , , , , etc.) — BigQuery / Databricks / Postgres / Redshift convention. On Snowflake, reference these UPPERCASE (, , ...). See
carto-create-workflow/references/providers/<provider>.md
for casing rules and SQL dialect equivalents.
- Isolines and routing components consume LDS (Location Data Services) quota. Check available quota with before bulk operations. Buffers () do not consume LDS quota and are a free alternative for simple circular catchments.
- OD matrices grow quadratically: N origins x M destinations = N*M rows. Filter or sample inputs to keep the matrix manageable. For 1000 origins x 1000 destinations, you get 1 million rows.
- Walking mode has a much shorter practical range than driving. Walking isolines beyond 20-30 minutes or OD matrices beyond a few kilometers produce unreliable or empty results.
- Route geometries can be large. For pure analytics (time/distance only), prefer the OD matrix (Pattern B) over full routes (Pattern C) to reduce data volume.
- Time-of-day affects driving results due to congestion. Specify if the component supports it; otherwise results reflect typical/average conditions.
- Isoline polygons may overlap for nearby locations. If enriching afterwards, polyfill to a spatial index and deduplicate cells to avoid double-counting.
- For OD flow visualization (Pattern D), use H3 cell center points rather than raw coordinates for cleaner aggregation and visualization. A coarser resolution (e.g. H3 res 7-8) produces more meaningful flow patterns than fine resolutions.
- The LDS routing components require a connection with LDS API access enabled. Validation may fail if the connection lacks this permission.
Reference Templates
Common Variations
| Variant | How |
|---|
| Service area coverage | Isolines (car, multiple ranges e.g. 5/10/15 min) -> union -> measure total population covered |
| Nearest facility | OD matrix -> group by origin -> min(duration_s) -> join back to get nearest destination ID |
| Accessibility scoring | OD matrix -> filter by threshold -> count destinations per origin -> score by reachable count |
| Fleet route planning | Routes between depot and delivery points -> aggregate total distance/time per route |
| Commute flow analysis | Trip data -> H3 origin + H3 destination -> group by OD pair -> count -> visualize top flows |
| Multi-modal comparison | Run isolines twice (car + walk) -> compare coverage polygons -> identify transit-dependent areas |