[ANN] KeplerGL.jl: Geospatial Visualization via Kepler.gl

Dear all,

Following some merry christmas hacking, I’m happy to announce a prototype of KeplerGL.jl, a package to provide an interface to the javascript library Kepler.gl.

Kepler.gl provides an easy-to-use platform to produce interactive maps: you drag & drop some CSV, JSON, or GeoJSON files into the browser window, click a few butttons to create point, line, hexbin, or polygon layers, and export your maps via html or png. It’s really very intuitive, fast, and looks terrific.

While this interactive way of creating maps is very convenient for quick inspections of geodata, it also makes it difficult to integrate into a code-based workflow. This is where the KeplerGL.jl Julia package comes in. It provides an interface to create the map layers via Julia code; the package then creates a html/javascript page that is then shown in a browser window via Blink.jl (and the Kepler.gl javascript libraries). Finally you can call a function to export static png’s. For example, the above visualization of building footprints in San Francisco is a couple of lines of code.

Here’s how to create a simple but good-looking point map:

using KeplerGL, CSV, Colors, ColorBrewer, DataFrames


m = KeplerGL.KeplerGLMap(token)
df = CSV.read("assets/example_data/data.csv", DataFrame)
KeplerGL.add_point_layer!(m, df, :Latitude, :Longitude,
    color = colorant"rgb(23,184,190)", color_field = :Magnitude, 
    color_scale = "quantize", 
    color_range = ColorBrewer.palette("PRGn", 6),
    radius_field = :Magnitude, radius_scale = "sqrt", 
    radius_range = [4.2, 96.2], radius_fixed = false,
    filled = true, opacity = 0.39, outline = false);

At this point there are probably plenty of bugs, and the package is not feature-complete. I hope to implement at least support for all layer types that are in Kepler.gl. I’m not very familiar with Julia’s Geo ecosystem and am therefore probably not going to provide direct support for this myself, but (if there’s demand) I’m happy to merge PRs as long as the usability for non-expert users (“I have some lat/lon coordinates in a vector and want to splash this on a map”) is not affected.

Barring the discovery of some disastrous bugs, I’ll register the package in the next couple of days.

Comments and bug reports are very welcome. Thanks!


Very nice! It would be interesting to experiment with this visualization stack in parallel to the Makie.jl stack. How would you reproduce the examples in the book using the Kepler API:


Kepler.gl can process GeoJSONs natively, but my interface doesn’t quite support it yet, so it’s a bit more cumbersome:

using KeplerGL, Colors, DataFrames, JSON3

token = "..."

# process GeoJSON
t = JSON3.read("geotable.geojson")
df = DataFrame(:geometry => string.(t[:features]))
df.colval = [1,2,3,4]

col = parse.(Colorant,["#450154", "#2f688e", "#37b679", "#fee724"])

m = KeplerGLMap(token)
KeplerGL.add_polygon_layer!(m, df, :geometry,
    color_field = :colval, color_range = col)

# lines
# seg = [Segment((-40, -10), (0, 0)), Segment((-40, 0), (-20, 10))]
df_lines = DataFrame(:orig_lon => [-40.0, -40.0], :orig_lat => [-10.0, 0.0],
    :dest_lon => [0.0, -20.0], :dest_lat => [0.0, 10.0],
    :color => [1, 4])

KeplerGL.add_line_layer!(m, df_lines, :orig_lat, :orig_lon, :dest_lat, :dest_lon,
    color_field = :color, color_range = col)

# points
# pts = [Point(-20, -10), Point(-20, 0), Point(-40, 10)]
df_points = DataFrame(:lat => [-10.0, 0.0, 10.0], :lon => [-20.0, -20.0, -40.0], :col => [1,2,3])
KeplerGL.add_point_layer!(m, df_points, :lat, :lon,
    color_field = :col, color_range = col, radius = 10.0)

# render

1 Like

The package is now registered; to install type

] add KeplerGL

At this point all layer types that are supported by Kepler.gl 2.5.5 are implemented (except S2 layers; I don’t think there is a package to work with S2 in Julia). The docs are in a decent state. The interface regarding map options could (and probably will) be improved, but I think the package is ready to be let out into the wild.