Skip to content

Getting started

Core concepts

Five ideas cover everything kharita does.

1. A style is a list of utilities

"fill-[density] ramp-ylorrd scheme-q5 stroke-white stroke-1 legend-br"

Each word sets one thing. Order does not matter. Two words that set the same thing, such as fill-red-500 fill-blue-500, raise StyleSyntaxError with the position of the clash and a suggestion. A typo gets the closest real utility: ramp-viridus suggests ramp-viridis.

2. Data goes in brackets

Write Means
[pop] a column
['pop/km2'] a column with odd characters, quoted
[pop/area] a ratio of two columns; dividing by zero shows as no data
[pop*1000] a column times a number
[median income] spaces are fine

Anything else is read as one column name, so [pop+1] looks for a column called pop+1. Do other arithmetic in pandas and pass the new column.

3. Classification has good defaults

A numeric column gets ramp-viridis scheme-q5 (or the theme's ramp); a text column gets ramp-set2 scheme-cat. Change either with ramp- and scheme-. See Classification.

4. Maps hold layers

Call Gives
kh.map(gdf, style) one layer, one map
kh.Map(title=...).add(a, style_a).add(b, style_b) several layers on one map
kh.layer(gdf, style) native Lonboard layers, for your own lonboard.Map
kh.legend(gdf, style) the legend HTML alone
kh.bind(gdf, style) the colours, sizes and class breaks as arrays

Map-wide settings, such as the basemap, theme, relief, buildings and labels, come from the first layer that sets them.

5. The map frame is styled with the same words

Titles and legends take card styles, Tailwind words for their look and place: title_style="top-center bg-white/80 font-serif text-3xl". See Card styles.

Tools for reading styles

kh.help()            # every utility
kh.help("scheme")    # syntax and examples for one
kh.explain("fill-[pop] scheme-q5 theme-midnight")   # what each word set, and the defaults
kh.validate("fill-[pop]", columns=states.columns)   # check a style against a table