Skip to content

Choropleth

image image image

Creating choropleth maps with a variety of classification schemes

Uncomment the following line to install leafmap if needed.

1
# %pip install "leafmap[maplibre]"
1
import leafmap.maplibregl as leafmap
1
data = "https://github.com/opengeos/datasets/releases/download/vector/countries.geojson"

Available classification schemes: * BoxPlot * EqualInterval * FisherJenks * FisherJenksSampled * HeadTailBreaks * JenksCaspall * JenksCaspallForced * JenksCaspallSampled * MaxP * MaximumBreaks * NaturalBreaks * Quantiles * Percentiles * StdMean * UserDefined

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
m = leafmap.Map(style="liberty")
first_symbol_id = m.find_first_symbol_layer()["id"]
m.add_data(
    data,
    column="POP_EST",
    scheme="Quantiles",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
    extrude=True,
    scale_factor=1000,
)
m.add_layer_control()
m

image

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(style="liberty")
m.add_data(
    data,
    column="POP_EST",
    scheme="Quantiles",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
)
m.add_layer_control()
m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(style="liberty")
m.add_data(
    data,
    column="POP_EST",
    scheme="EqualInterval",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
)
m.add_layer_control()
m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(style="liberty")
m.add_data(
    data,
    column="POP_EST",
    scheme="FisherJenks",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
)
m.add_layer_control()
m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(style="liberty")
m.add_data(
    data,
    column="POP_EST",
    scheme="FisherJenks",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
)
m.add_layer_control()
m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(style="liberty")
m.add_data(
    data,
    column="POP_EST",
    scheme="JenksCaspall",
    cmap="Blues",
    legend_title="Population",
    name="Population",
    before_id=first_symbol_id,
)
m.add_layer_control()
m