Scattermapbox
Overview
The scattermapbox insight type is used to create scatter plots on a Mapbox map. This is ideal for visualizing geospatial data with the added customization and interactivity that Mapbox provides, including satellite imagery and street maps.
You can plot geographic points with latitude and longitude and customize the marker size, color, and labels to represent data effectively.
Common Uses
- Geospatial Analysis: Plotting geographic points on an interactive map.
- Location-Based Data: Visualizing locations and patterns on a Mapbox map.
- Mapping Events: Plotting real-world events, like earthquakes or delivery points.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
sources:
- name: scattermapbox-data-source
type: duckdb
database: target/seeds/scattermapbox_data.duckdb
seeds:
- table_name: model
args:
- echo
- |
lon,lat
-73.9857,40.7484
-118.2437,34.0522
-0.1276,51.5074
139.6917,35.6895
models:
- name: scattermapbox-data
source: ${ref(scattermapbox-data-source)}
sql: select * from model
insights:
- name: Simple Scattermapbox Insight
props:
type: scattermapbox
lon: ?{${ref(scattermapbox-data).lon}}
lat: ?{${ref(scattermapbox-data).lat}}
mode: "markers"
marker:
size: 10
interactions:
- split: ?{ lon }
- split: ?{ lat }
charts:
- name: Simple Scattermapbox Chart
insights:
- ${ref(Simple Scattermapbox Insight)}
layout:
mapbox:
style: "open-street-map"
title:
text: Simple Scattermapbox Plot<br><sub>Geographical Data Points on Mapbox</sub>
sources:
- name: scattermapbox-data-lines-source
type: duckdb
database: target/seeds/scattermapbox_data_lines.duckdb
seeds:
- table_name: model
args:
- echo
- |
lon,lat
-73.9857,40.7484
-118.2437,34.0522
-0.1276,51.5074
139.6917,35.6895
models:
- name: scattermapbox-data-lines
source: ${ref(scattermapbox-data-lines-source)}
sql: select * from model
insights:
- name: Scattermapbox Insight with Lines
props:
type: scattermapbox
lon: ?{${ref(scattermapbox-data-lines).lon}}
lat: ?{${ref(scattermapbox-data-lines).lat}}
mode: "lines+markers"
marker:
size: 10
interactions:
- split: ?{ lon }
- split: ?{ lat }
charts:
- name: Scattermapbox Chart with Lines
insights:
- ${ref(Scattermapbox Insight with Lines)}
layout:
mapbox:
style: "satellite-streets"
title:
text: Scattermapbox Plot with Lines<br><sub>Connecting Geographic Points on Mapbox</sub>
sources:
- name: scattermapbox-data-custom-source
type: duckdb
database: target/seeds/scattermapbox_data_custom.duckdb
seeds:
- table_name: model
args:
- echo
- |
lon,lat,size,color
-73.9857,40.7484,10,#1f77b4
-118.2437,34.0522,15,#ff7f0e
-0.1276,51.5074,20,#2ca02c
139.6917,35.6895,25,#d62728
models:
- name: scattermapbox-data-custom
source: ${ref(scattermapbox-data-custom-source)}
sql: select * from model
insights:
- name: Scattermapbox Insight with Custom Markers
props:
type: scattermapbox
lon: ?{${ref(scattermapbox-data-custom).lon}}
lat: ?{${ref(scattermapbox-data-custom).lat}}
mode: "markers"
marker:
size: ?{${ref(scattermapbox-data-custom).size}}
color: ?{${ref(scattermapbox-data-custom).color}}
interactions:
- split: ?{ lon }
- split: ?{ lat }
- split: ?{ color }
charts:
- name: Scattermapbox Chart with Custom Markers
insights:
- ${ref(Scattermapbox Insight with Custom Markers)}
layout:
mapbox:
style: "dark"
title:
text: Scattermapbox Plot with Custom Markers<br><sub>Custom Sizes and Colors for Geographic Data Points</sub>