Skip to content

Scattergeo

Overview

The scattergeo insight type is used to create scatter plots on a geographic map. This type of plot is ideal for visualizing data points with geographic coordinates, allowing for the exploration of patterns, distributions, or trends over geographical areas.

You can customize the marker size, color, and geo-coordinates (longitude and latitude) to effectively represent the geographic data.

Common Uses

  • Geospatial Data: Visualizing points or patterns on a geographic map.
  • Location-Based Analysis: Exploring the distribution of data points across different locations.
  • Mapping: Plotting geographical points such as cities, events, or regions.

Check out the Attributes for the full set of configuration options

Examples

Common Configurations

Here's a simple scattergeo insight showing data points at various geographic locations:

sources:
  - name: scattergeo-data-source
    type: duckdb
    database: target/seeds/scattergeo_data.duckdb
    seeds:
      - table_name: model
        args:
          - echo
          - |
            lon,lat
            -75,40
            -80,25
            -120,47
            -100,35
            -90,30
models:
  - name: scattergeo-data
    source: ${ref(scattergeo-data-source)}
    sql: select * from model
insights:
  - name: Simple Scattergeo Insight
    props:
      type: scattergeo
      lon: ?{${ref(scattergeo-data).lon}}
      lat: ?{${ref(scattergeo-data).lat}}
      mode: "markers"
    interactions:
      - split: ?{ lon }
      - split: ?{ lat }
charts:
  - name: Simple Scattergeo Chart
    insights:
      - ${ref(Simple Scattergeo Insight)}
    layout:
      title:
        text: Simple Scattergeo Plot<br><sub>Geographical Data Points</sub>
      geo:
        scope: "usa"

This example demonstrates a scattergeo insight with lines connecting geographic points:

sources:
  - name: scattergeo-data-lines-source
    type: duckdb
    database: target/seeds/scattergeo_data_lines.duckdb
    seeds:
      - table_name: model
        args:
          - echo
          - |
            lon,lat
            -75,40
            -80,25
            -120,47
            -100,35
            -90,30
models:
  - name: scattergeo-data-lines
    source: ${ref(scattergeo-data-lines-source)}
    sql: select * from model
insights:
  - name: Scattergeo Insight with Lines
    props:
      type: scattergeo
      lon: ?{${ref(scattergeo-data-lines).lon}}
      lat: ?{${ref(scattergeo-data-lines).lat}}
      mode: "lines+markers"
    interactions:
      - split: ?{ lon }
      - split: ?{ lat }
charts:
  - name: Scattergeo Chart with Lines
    insights:
      - ${ref(Scattergeo Insight with Lines)}
    layout:
      title:
        text: Scattergeo Plot with Lines<br><sub>Connecting Geographic Points</sub>
      geo:
        scope: "world"

Here's a scattergeo insight with custom marker sizes and colors, giving more visual weight to each geographic data point:

sources:
  - name: scattergeo-data-custom-source
    type: duckdb
    database: target/seeds/scattergeo_data_custom.duckdb
    seeds:
      - table_name: model
        args:
          - echo
          - |
            lon,lat,size,color
            -75,40,10,#1f77b4
            -80,25,15,#ff7f0e
            -120,47,20,#2ca02c
            -100,35,25,#d62728
            -90,30,30,#9467bd
models:
  - name: scattergeo-data-custom
    source: ${ref(scattergeo-data-custom-source)}
    sql: select * from model
insights:
  - name: Scattergeo Insight with Custom Markers
    props:
      type: scattergeo
      lon: ?{${ref(scattergeo-data-custom).lon}}
      lat: ?{${ref(scattergeo-data-custom).lat}}
      mode: "markers"
      marker:
        size: ?{${ref(scattergeo-data-custom).size}}
        color: ?{${ref(scattergeo-data-custom).color}}
    interactions:
      - split: ?{ lon }
      - split: ?{ lat }
      - split: ?{ color }
charts:
  - name: Scattergeo Chart with Custom Markers
    insights:
      - ${ref(Scattergeo Insight with Custom Markers)}
    layout:
      title:
        text: Scattergeo Plot with Custom Markers<br><sub>Custom Sizes and Colors for Geographic Data Points</sub>
      geo:
        scope: "north america"