DeckGL.jl

Interactive maps in Julia.

GPU-accelerated geospatial visualization. Millions of points. Smooth pan, zoom, 3D. Built on deck.gl.

Real airline routes between the world’s 40 busiest airports, from the OpenFlights database.

using DeckGL, Downloads

let
    #--------------------------------------------------------------------------------# CSV parser for OpenFlights format (handles quoted fields)
    function parse_of_line(line)
        fields = String[]
        buf = IOBuffer()
        in_q = false
        for c in line
            if c == '"'
                in_q = !in_q
            elseif c == ',' && !in_q
                push!(fields, String(take!(buf)))
            else
                write(buf, c)
            end
        end
        push!(fields, String(take!(buf)))
        return fields
    end

    #--------------------------------------------------------------------------------# Download OpenFlights data
    airports_file = Downloads.download(
        "https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat"
    )
    routes_file = Downloads.download(
        "https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat"
    )

    # Parse airports: IATA → (lat, lng)
    airport_db = Dict{String, @NamedTuple{lat::Float64, lng::Float64}}()
    for line in readlines(airports_file)
        f = parse_of_line(line)
        length(f) >= 8 || continue
        iata = f[5]
        (iata == "" || iata == "\\N" || length(iata) != 3) && continue
        lat = tryparse(Float64, f[7])
        lng = tryparse(Float64, f[8])
        (lat === nothing || lng === nothing) && continue
        airport_db[iata] = (lat = lat, lng = lng)
    end

    # Parse routes: collect direct-flight pairs (deduplicated)
    route_set = Set{Tuple{String,String}}()
    for line in readlines(routes_file)
        f = split(line, ',')
        length(f) >= 8 || continue
        src, dst, stops = f[3], f[5], f[8]
        stops == "0" || continue
        haskey(airport_db, src) && haskey(airport_db, dst) || continue
        push!(route_set, src < dst ? (src, dst) : (dst, src))
    end

    # Rank airports by connectivity, pick top 40
    counts = Dict{String,Int}()
    for (s, d) in route_set
        counts[s] = get(counts, s, 0) + 1
        counts[d] = get(counts, d, 0) + 1
    end
    top = Set(first.(sort(collect(counts), by = last, rev = true)[1:min(40, length(counts))]))

    # Filter to routes between top airports
    sel_routes = [(s, d) for (s, d) in route_set if s in top && d in top]
    sel_routes = sel_routes[1:min(250, length(sel_routes))]

    used = sort(collect(union(Set(first.(sel_routes)), Set(last.(sel_routes)))))

    airports = (
        lng  = [airport_db[a].lng for a in used],
        lat  = [airport_db[a].lat for a in used],
        name = used,
    )
    routes = (
        src_lng = [airport_db[r[1]].lng for r in sel_routes],
        src_lat = [airport_db[r[1]].lat for r in sel_routes],
        tgt_lng = [airport_db[r[2]].lng for r in sel_routes],
        tgt_lat = [airport_db[r[2]].lat for r in sel_routes],
    )

    arcs = ArcLayer(
        data = routes,
        get_source_position = [:src_lng, :src_lat],
        get_target_position = [:tgt_lng, :tgt_lat],
        get_source_color = [0, 180, 235, 160],
        get_target_color = [160, 90, 255, 160],
        get_width = 1,
        great_circle = true,
    )
    dots = ScatterplotLayer(
        data = airports,
        get_position = [:lng, :lat],
        get_fill_color = [0, 210, 235, 220],
        get_radius = 50000,
        radius_min_pixels = 3,
    )
    labels = TextLayer(
        data = airports,
        get_position = [:lng, :lat],
        get_text = :name,
        get_size = 11,
        get_color = [255, 255, 255, 230],
        get_pixel_offset = [0, -14],
        background = true,
        get_background_color = [30, 30, 30, 180],
        background_padding = [4, 2, 4, 2],
        font_family = "Helvetica, Arial, sans-serif",
        font_weight = 700,
    )

    deck = Deck(
        [arcs, dots, labels],
        initial_view_state = ViewState(longitude = 20.0, latitude = 15.0, zoom = 1.5, pitch = 15.0),
        map_style = "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
    )
    save_html(deck, "examples/global-flight-routes.html")
end

Overview

  • Big data, smooth frames — WebGL rendering of millions of points.
  • Any Tables.jl source — DataFrames, NamedTuples, CSV.jl, Arrow.jl, …
  • All 32 deck.gl layers — scatter, arc, path, polygon, text, hexbin, heatmap, contour, GeoJSON, vector and raster tiles, terrain, H3/S2/geohash/quadkey cells, 3D meshes.
  • Any display target — Jupyter, Pluto, VS Code, standalone HTML.
  • Declarative API — layers, view state, widgets. That’s it.

Install:

using Pkg
Pkg.add(url="https://github.com/RallypointOne/DeckGL.jl")

Quickstart

using DeckGL

cities = (
    lng  = [-122.4, -74.0,   2.35, 139.7, 151.2, -0.13, 77.22, 103.8],
    lat  = [  37.8,  40.7,  48.86,  35.7, -33.9,  51.5, 28.61,   1.35],
    pop  = [   870, 8400,   2100, 13900,  5300,  9000, 32000,  5700],
)

Deck(
    ScatterplotLayer(
        data = cities,
        get_position = [:lng, :lat],
        get_radius = :pop,
        radius_scale = 80,
        radius_min_pixels = 4,
        get_fill_color = [255, 140, 0, 220],
    ),
    initial_view_state = ViewState(longitude=30, latitude=25, zoom=1.2, pitch=20),
    map_style = "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
)

A Deck has four pieces:

  1. Layers — what to draw.
  2. ViewState — where the camera is (longitude, latitude, zoom, pitch, bearing).
  3. map_style — the basemap drawn underneath, as a MapLibre style URL. Carto’s are free and need no API key: swap dark-matter above for positron or voyager. Omit it for a blank background.
  4. Widgets (optional) — UI overlays.

Layer props may be written snake_case or camelCase, and anything left unset keeps deck.gl’s own default.

Columns are referenced by Symbol: get_radius = :pop, get_position = [:lng, :lat]. Static values work too: get_fill_color = [255, 140, 0, 220].

Display

  • Notebooks (Jupyter, Pluto, VS Code) — a Deck renders inline automatically.
  • Browser — open_html(deck) pops a tab.
  • File — save_html(deck, "map.html").
  • String — to_html(deck), or to_js(deck) for just the JavaScript.

Where to go next

  • Examples → — flight routes, earthquakes, 3D buildings, wildfires, trees, accidents.
  • Layers → — all 32 layer types with a live interactive example.
  • Widgets → — all 15 UI overlays: zoom, compass, popups, screenshots, themes.
  • API → — full reference.