Skip to content

Styling data

Stroke and lines

Outlines of polygons and points, and the colour, width and dashes of lines.

Quick reference

Utility Does Example
stroke-<colour>
stroke-<pixels>
stroke-[<expr>]
Outline or line colour, its width in pixels, or line colour by data stroke-white
stroke-slate-300/50
stroke-1
width-[<expr>]
width-max-<pixels>
Line or outline width by data, the widest set by width-max width-[rank]
width-[flow/1000]
width-max-10
dash-<on>-<off>
dash-<n>
Dashed lines and outlines, in line widths dash-4-2
dash-3
dash-1.5-1

Colour and width

stroke-white stroke-1 gives polygons a one-pixel white outline. On a line layer, stroke- is the line itself, and stroke-[road_class] colours lines by data.

Width by data

width-[rank] makes line width follow a column: the widest line is width-max pixels (default 8) and no line is thinner than half a pixel. The legend adds a line-width key.

stroke-lines

kh.map(roads, "basemap-muted stroke-[road_class] ramp-set2 width-[rank] width-max-5",
       legend={"title": "Road class"})

Dashes

dash-4-2 draws 4 units on, 2 off, in multiples of the line width; dash-3 is 3 on, 3 off. Dashes apply to lines and outlines, the way disputed borders and planned routes are drawn.

kh.map(states, "basemap-paper fill-transparent stroke-slate-700 stroke-1.5 dash-4-2")