Skip to content

Reference

kharita compared

How kharita fits among the Python map libraries you may already use, and when another one is the better choice.

kharita is not a new map engine. It sits on top of Lonboard and adds the parts of a finished map that are usually written by hand: classes, colours, a legend, a title and a designed basemap, all from one style string.

At a glance

Library Built on Best for Styling
kharita Lonboard (deck.gl) Finished, designed interactive maps from GeoPandas in a few lines, including large data One string of utilities: fill-[pop] ramp-viridis scheme-q5; legend and title built for you
Lonboard deck.gl, GeoArrow Very large data on the GPU, full control of each layer Arrays of colours and sizes you compute, layer by layer
folium Leaflet.js Small to medium data, many Leaflet plugins, simple web maps Python objects and style functions; GeoJSON is embedded in the page
GeoPandas explore() folium A quick interactive look at a GeoDataFrame Keyword arguments: column, scheme, colour map
GeoPandas plot() matplotlib Static maps for papers and print matplotlib arguments
pydeck deck.gl deck.gl layers from Python, many layer types deck.gl layer properties and expressions
Plotly Plotly.js, MapLibre Maps inside Plotly charts and Dash apps Plotly Express arguments

The same map, three ways

A choropleth of population density in five quantile classes, with a legend.

kh.map(states, "fill-[density] ramp-ylorrd scheme-q5 stroke-white",
       legend={"title": "People per km2"})
states.explore(column="density", scheme="quantiles", k=5, cmap="YlOrRd",
               legend_kwds={"caption": "People per km2"})
breaks = np.quantile(states["density"], [0.2, 0.4, 0.6, 0.8])
palette = np.array([[255, 255, 178], [254, 204, 92], [253, 141, 60],
                    [240, 59, 32], [189, 0, 38]], dtype=np.uint8)
layer = PolygonLayer.from_geopandas(
    states, get_fill_color=palette[np.digitize(states["density"], breaks)],
    get_line_color=[255, 255, 255])
Map(layer)  # then a legend and a title by hand

When to choose kharita

  • You want a map that looks finished, with a legend, title and designed basemap, without writing them.
  • Your data is large enough that a GeoJSON map slows down, and you still want classes and a legend.
  • You want the same short style on every map in a notebook, a report or a team.

When to choose something else

  • Static figures for print or a paper: GeoPandas plot(), matplotlib or Cartopy.
  • Leaflet plugins, such as marker clusters or drawing tools: folium.
  • A dashboard with charts and maps together: Plotly and Dash.
  • Full control of every deck.gl setting: Lonboard directly. kh.layer() returns plain Lonboard layers, so you can start with kharita and finish by hand.

See also what kharita is not for.