All skills
mapbox avatar

/mapbox-data-visualization-patterns

@65bab68 official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Patterns for visualizing data on maps including choropleth maps, heat maps, 3D visualizations, data-driven styling, and animated data. Covers layer types, color scales, and performance optimization.

Use this Skill: https://skilld.dev/gh/mapbox/mapbox-agent-skills/mapbox-data-visualization-patterns

This session only. Nothing lands on disk.

referencesclustering.md

≈983 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Clustering (Point Density)

Best for: Grouping nearby points, aggregated counts, large point datasets

Pattern: Client-side clustering for visualization

Clustering is a valuable point density visualization technique alongside heat maps. Use clustering when you want discrete grouping with exact counts rather than a continuous density visualization.

map.on('load', () => {
  // Add data source with clustering enabled
  map.addSource('locations', {
    type: 'geojson',
    data: {
      type: 'FeatureCollection',
      features: [
        // Your point features
      ]
    },
    cluster: true,
    clusterMaxZoom: 14, // Max zoom to cluster points
    clusterRadius: 50 // Radius of each cluster (default 50)
  });

  // Clustered circles - styled by point count
  map.addLayer({
    id: 'clusters',
    type: 'circle',
    source: 'locations',
    filter: ['has', 'point_count'],
    paint: {
      // Color clusters by count (step expression)
      'circle-color': ['step', ['get', 'point_count'], '#51bbd6', 10, '#f1f075', 30, '#f28cb1'],
      // Size clusters by count
      'circle-radius': ['step', ['get', 'point_count'], 20, 10, 30, 30, 40]
    }
  });

  // Cluster count labels
  map.addLayer({
    id: 'cluster-count',
    type: 'symbol',
    source: 'locations',
    filter: ['has', 'point_count'],
    layout: {
      'text-field': ['get', 'point_count_abbreviated'],
      'text-font': ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],
      'text-size': 12
    }
  });

  // Individual unclustered points
  map.addLayer({
    id: 'unclustered-point',
    type: 'circle',
    source: 'locations',
    filter: ['!', ['has', 'point_count']],
    paint: {
      'circle-color': '#11b4da',
      'circle-radius': 6,
      'circle-stroke-width': 1,
      'circle-stroke-color': '#fff'
    }
  });

  // Click handler to expand clusters
  map.on('click', 'clusters', (e) => {
    const features = map.queryRenderedFeatures(e.point, {
      layers: ['clusters']
    });
    const clusterId = features[0].properties.cluster_id;

    // Get cluster expansion zoom
    map.getSource('locations').getClusterExpansionZoom(clusterId, (err, zoom) => {
      if (err) return;

      map.easeTo({
        center: features[0].geometry.coordinates,
        zoom: zoom
      });
    });
  });

  // Change cursor on hover
  map.on('mouseenter', 'clusters', () => {
    map.getCanvas().style.cursor = 'pointer';
  });
  map.on('mouseleave', 'clusters', () => {
    map.getCanvas().style.cursor = '';
  });
});

Advanced: Custom Cluster Properties

map.addSource('locations', {
  type: 'geojson',
  data: data,
  cluster: true,
  clusterMaxZoom: 14,
  clusterRadius: 50,
  // Calculate custom cluster properties
  clusterProperties: {
    // Sum total values
    sum: ['+', ['get', 'value']],
    // Calculate max value
    max: ['max', ['get', 'value']]
  }
});

// Use custom properties in styling
'circle-color': [
  'interpolate',
  ['linear'],
  ['get', 'sum'],
  0,
  '#51bbd6',
  100,
  '#f1f075',
  1000,
  '#f28cb1'
];

When to use clustering vs heatmaps:

Use Case Clustering Heatmap
Visual style Discrete circles with counts Continuous gradient
Interaction Click to expand/zoom Visual density only
Data granularity Exact counts visible Approximate density
Best for Store locators, event listings Crime maps, incident areas
Performance with many points Excellent (groups automatically) Good
User understanding Clear (numbered clusters) Intuitive (heat analogy)

Source: SKILL.md on GitHub

No alerts14d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    The skill provides comprehensive patterns for Mapbox data visualizations. It is generally safe, but it identifies an attack surface for indirect prompt injection by demonstrating how to ingest external data and display properties in UI components without sanitization or boundary markers.

  • Socket14d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer6mo

    2 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 65bab68. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 hours ago.

Activeupdated 6 months ago
  • mapbox
  • choropleth
  • heatmap
  • 3d-extrusion
  • data-driven-styling
  • geojson
  • vector-tiles
  • animation
  • cartography

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-data-visualization-patterns

Teaches patterns for visualizing statistical and geographic data on Mapbox maps, including choropleth maps, heat maps, 3D extrusions, data-driven styling, and animation. Covers layer types, color scales, accessibility, and performance optimization for datasets up to vector tilesets.

Generated from the current SKILL.md.

Does this skill cover vector tiles or only GeoJSON?
It covers both. The skill recommends GeoJSON for datasets under 1 MB, vector tiles for datasets over 10 MB. See the performance reference file for implementation details.
What color scale strategies does this skill include?
Three main strategies: linear interpolation for continuous gradients, step intervals for discrete buckets, and match-based styling for categorical data. ColorBrewer scales are recommended for accessibility.
Does this skill cover 3D visualizations?
Yes. The skill includes patterns for 3D building extrusions and terrain elevation, with detailed implementation in the 3d-extrusions reference file.
Can this skill handle real-time or animated data?
Yes. The animation reference file covers time-series animation, real-time data updates, and smooth transitions.
What layer types are covered?
Choropleth (fill layers), heat maps, circle/bubble maps, line visualizations, and 3D extrusions. Additional patterns are available in referenced files for clustering and custom styling.

Generated from the current SKILL.md. These answers refresh after source changes.