Diverging Colormap
Encode neighborhood area with a diverging Spectral colormap normalized by percentiles.
Python Script
python
from __future__ import annotations
import json
from pathlib import Path
import pyautark as ak
DATA_DIR = Path(__file__).resolve().parents[1] / "data"
with (DATA_DIR / "mnt_neighs.geojson").open(encoding="utf-8") as f:
neighborhoods_data = json.load(f)
neighborhoods = ak.GeoJSON(
"neighborhoods",
values=neighborhoods_data,
layer_type="polygons",
)
neighborhoods_layer = ak.Layer(
neighborhoods,
id="neighborhoods_layer",
encoding=ak.Encoding(
color=ak.field(
"properties.shape_area",
ak.Scale(type="quantile", scheme="spectral"),
)
),
)
spec = ak.Spec(data=[neighborhoods], views=[ak.Map(layers=[neighborhoods_layer])])
if __name__ == "__main__":
spec.window(height="760px")Run in Jupyter or standalone HTML
Replace spec.window(...) with spec.widget() inside a Jupyter notebook (requires pip install "pyautark[widget]") or spec.save_html("out.html") to export a standalone web page.
This example comes from the pyautark repository.