← 返回 Skills 市场
🔌

Mapbox Data Visualization Patterns

作者 Mapbox · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
149
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install mapbox-data-visualization-patterns
功能描述
Patterns for visualizing data on maps including choropleth maps, heat maps, 3D visualizations, data-driven styling, and animated data. Covers layer types, co...
使用说明 (SKILL.md)

Data Visualization Patterns Skill

Comprehensive patterns for visualizing data on Mapbox maps. Covers choropleth maps, heat maps, 3D extrusions, data-driven styling, animated visualizations, and performance optimization for data-heavy applications.

When to Use This Skill

Use this skill when:

  • Visualizing statistical data on maps (population, sales, demographics)
  • Creating choropleth maps with color-coded regions
  • Building heat maps or clustering for density visualization
  • Adding 3D visualizations (building heights, terrain elevation)
  • Implementing data-driven styling based on properties
  • Animating time-series data
  • Working with large datasets that require optimization

Visualization Types

Choropleth Maps

Best for: Regional data (states, counties, zip codes), statistical comparisons

Pattern: Color-code polygons based on data values

map.on('load', () => {
  // Add data source (GeoJSON with properties)
  map.addSource('states', {
    type: 'geojson',
    data: 'https://example.com/states.geojson' // Features with population property
  });

  // Add fill layer with data-driven color
  map.addLayer({
    id: 'states-layer',
    type: 'fill',
    source: 'states',
    paint: {
      'fill-color': [
        'interpolate',
        ['linear'],
        ['get', 'population'],
        0,
        '#f0f9ff', // Light blue for low population
        500000,
        '#7fcdff',
        1000000,
        '#0080ff',
        5000000,
        '#0040bf', // Dark blue for high population
        10000000,
        '#001f5c'
      ],
      'fill-opacity': 0.75
    }
  });

  // Add border layer
  map.addLayer({
    id: 'states-border',
    type: 'line',
    source: 'states',
    paint: {
      'line-color': '#ffffff',
      'line-width': 1
    }
  });

  // Add hover effect with reusable popup
  const popup = new mapboxgl.Popup({
    closeButton: false,
    closeOnClick: false
  });

  map.on('mousemove', 'states-layer', (e) => {
    if (e.features.length > 0) {
      map.getCanvas().style.cursor = 'pointer';

      const feature = e.features[0];
      popup
        .setLngLat(e.lngLat)
        .setHTML(
          `
          \x3Ch3>${feature.properties.name}\x3C/h3>
          \x3Cp>Population: ${feature.properties.population.toLocaleString()}\x3C/p>
        `
        )
        .addTo(map);
    }
  });

  map.on('mouseleave', 'states-layer', () => {
    map.getCanvas().style.cursor = '';
    popup.remove();
  });
});

step vs interpolate: The example above uses interpolate for smooth color gradients. For discrete color buckets (e.g., "low / medium / high"), use ['step', ['get', 'population'], '#f0f0f0', 500000, '#fee0d2', 2000000, '#fc9272', 10000000, '#de2d26'] instead. Prefer step when data has natural categories or when exact boundary values matter.

Color Scale Strategies:

// Linear interpolation (continuous scale)
'fill-color': [
  'interpolate',
  ['linear'],
  ['get', 'value'],
  0, '#ffffcc',
  25, '#78c679',
  50, '#31a354',
  100, '#006837'
]

// Step intervals (discrete buckets)
'fill-color': [
  'step',
  ['get', 'value'],
  '#ffffcc',  // Default color
  25, '#c7e9b4',
  50, '#7fcdbb',
  75, '#41b6c4',
  100, '#2c7fb8'
]

// Case-based (categorical data)
'fill-color': [
  'match',
  ['get', 'category'],
  'residential', '#ffd700',
  'commercial', '#ff6b6b',
  'industrial', '#4ecdc4',
  'park', '#45b7d1',
  '#cccccc'  // Default
]

Heat Maps

Best for: Point density, event locations, incident clustering

Pattern: Visualize density of points

map.on('load', () => {
  // Add data source (points)
  map.addSource('incidents', {
    type: 'geojson',
    data: {
      type: 'FeatureCollection',
      features: [
        {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [-122.4194, 37.7749]
          },
          properties: {
            intensity: 1
          }
        }
        // ... more points
      ]
    }
  });

  // Add heatmap layer
  map.addLayer({
    id: 'incidents-heat',
    type: 'heatmap',
    source: 'incidents',
    maxzoom: 15,
    paint: {
      // Increase weight based on intensity property
      'heatmap-weight': ['interpolate', ['linear'], ['get', 'intensity'], 0, 0, 6, 1],
      // Increase intensity as zoom level increases
      'heatmap-intensity': ['interpolate', ['linear'], ['zoom'], 0, 1, 15, 3],
      // Color ramp for heatmap
      'heatmap-color': [
        'interpolate',
        ['linear'],
        ['heatmap-density'],
        0,
        'rgba(33,102,172,0)',
        0.2,
        'rgb(103,169,207)',
        0.4,
        'rgb(209,229,240)',
        0.6,
        'rgb(253,219,199)',
        0.8,
        'rgb(239,138,98)',
        1,
        'rgb(178,24,43)'
      ],
      // Adjust radius by zoom level
      'heatmap-radius': ['interpolate', ['linear'], ['zoom'], 0, 2, 15, 20],
      // Decrease opacity at higher zoom levels
      'heatmap-opacity': ['interpolate', ['linear'], ['zoom'], 7, 1, 15, 0]
    }
  });

  // Add circle layer for individual points at high zoom
  map.addLayer({
    id: 'incidents-point',
    type: 'circle',
    source: 'incidents',
    minzoom: 14,
    paint: {
      'circle-radius': ['interpolate', ['linear'], ['zoom'], 14, 4, 22, 30],
      'circle-color': '#ff4444',
      'circle-opacity': 0.8,
      'circle-stroke-color': '#fff',
      'circle-stroke-width': 1
    }
  });
});

Best Practices

Color Accessibility

// Use ColorBrewer scales for accessibility
// https://colorbrewer2.org/

// Good: Sequential (single hue)
const sequentialScale = ['#f0f9ff', '#bae4ff', '#7fcdff', '#0080ff', '#001f5c'];

// Good: Diverging (two hues)
const divergingScale = ['#d73027', '#fc8d59', '#fee08b', '#d9ef8b', '#91cf60', '#1a9850'];

// Good: Qualitative (distinct categories)
const qualitativeScale = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00'];

// Avoid: Red-green for color-blind accessibility
// Use: Blue-orange or purple-green instead

Error Handling

// Handle missing or invalid data
map.on('load', () => {
  map.addSource('data', {
    type: 'geojson',
    data: dataUrl
  });

  map.addLayer({
    id: 'data-viz',
    type: 'fill',
    source: 'data',
    paint: {
      'fill-color': [
        'case',
        ['has', 'value'], // Check if property exists
        ['interpolate', ['linear'], ['get', 'value'], 0, '#f0f0f0', 100, '#0080ff'],
        '#cccccc' // Default color for missing data
      ]
    }
  });

  // Handle map errors
  map.on('error', (e) => {
    console.error('Map error:', e.error);
  });
});

Data Size Rule

  • \x3C 1 MB: Use GeoJSON directly
  • 1–10 MB: Consider either GeoJSON or vector tiles depending on complexity
  • > 10 MB: Use vector tiles (upload to Mapbox as tileset)

See references/performance.md for implementation details.

Reference Files

For additional visualization patterns, load the relevant reference file:

Resources

安全使用建议
This skill appears coherent and low-risk: it's a documentation/instruction pack for Mapbox visualizations and requires no credentials or installs. Before using: replace placeholder endpoints (example.com, api.example.com) with your own trusted data sources; do not point examples at private endpoints unless you understand the data flow and CORS implications; if you use Mapbox services you will need a Mapbox access token in your app (the skill doesn't request one) — store that token securely and avoid pasting it into untrusted places; when running examples that fetch live data or open WebSockets, verify the remote service's trustworthiness to avoid inadvertently sending sensitive data. If you want higher assurance, request the author/source and any licensing/usage terms for included patterns or assets.
功能分析
Type: OpenClaw Skill Name: mapbox-data-visualization-patterns Version: 1.0.0 The skill bundle provides comprehensive and legitimate documentation, code patterns, and reference materials for Mapbox GL JS data visualization. It covers standard mapping techniques such as choropleth maps, heat maps, clustering, and 3D extrusions using the official Mapbox API. No evidence of malicious intent, data exfiltration, or prompt injection was found; all external URLs are placeholders (e.g., example.com), and the instructions are strictly aligned with the stated purpose of assisting developers with map styling and performance optimization.
能力评估
Purpose & Capability
Name/description match the content: examples, patterns, and guidance all relate to Mapbox GL JS visualizations. There are no unrelated environment variables, binaries, or config paths requested.
Instruction Scope
SKILL.md contains many concrete code examples that fetch or reference external data URLs (https://example.com, /api/live-data, wss://api.example.com) and demonstrates client-side data updates and WebSocket polling. This is expected for a visualization patterns skill, but users should replace the placeholder endpoints and validate any real endpoints they connect to.
Install Mechanism
No install spec and no code files are executed by the platform — lowest-risk pattern. A snippet references 'npm install classybrew' for preprocessing, but that's an optional example and not an installer declared by the skill.
Credentials
Skill declares no environment variables, credentials, or config paths. The examples do not attempt to access system secrets. No disproportionate credential requests are present.
Persistence & Privilege
always is false and the skill does not request persistent system presence or modify other skills. Autonomous invocation is allowed (platform default) but the skill has no elevated privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install mapbox-data-visualization-patterns
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /mapbox-data-visualization-patterns 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release providing best-practice patterns for data visualization on Mapbox maps. - Includes step-by-step guides for choropleth maps, heat maps, and 3D visualizations. - Covers color scale strategies for continuous and categorical data. - Offers tips for accessibility, error handling, and large dataset performance. - Reference files for advanced topics like clustering, animation, and optimization are linked.
元数据
Slug mapbox-data-visualization-patterns
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Mapbox Data Visualization Patterns 是什么?

Patterns for visualizing data on maps including choropleth maps, heat maps, 3D visualizations, data-driven styling, and animated data. Covers layer types, co... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 149 次。

如何安装 Mapbox Data Visualization Patterns?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install mapbox-data-visualization-patterns」即可一键安装,无需额外配置。

Mapbox Data Visualization Patterns 是免费的吗?

是的,Mapbox Data Visualization Patterns 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Mapbox Data Visualization Patterns 支持哪些平台?

Mapbox Data Visualization Patterns 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Mapbox Data Visualization Patterns?

由 Mapbox(@mapbox)开发并维护,当前版本 v1.0.0。

💬 留言讨论