JSON Data
Load a JSON dataset with coordinate columns into ak.JSON and visualize the resulting features on a map.
Python Script
python
"""Inline JSON data — pass a list of records as a JSON data source, then chart + table."""
from __future__ import annotations
from pathlib import Path
import pyautark as ak
stations_data = [
{"id": 1, "name": "Station A", "lat": 40.7128, "lon": -74.0060, "capacity": 50},
{"id": 2, "name": "Station B", "lat": 40.7580, "lon": -73.9855, "capacity": 75},
{"id": 3, "name": "Station C", "lat": 40.7489, "lon": -73.9680, "capacity": 60},
]
stations = ak.JSON("stations", values=stations_data, geometry=ak.latlng("lat", "lon"))
spec = ak.Spec(
metadata=ak.Metadata(title="Station Capacity"),
data=[stations],
views=[
ak.Map(layers=[ak.Layer(stations, id="stations").style(color="#e45756", size=300)]),
ak.Scatterplot(
source=stations,
x="id",
y="capacity",
color="name",
name="station_capacity",
),
ak.Table(
source=stations,
columns=["id", "name", "lat", "lon", "capacity"],
name="station_table",
),
],
layout=ak.Layout(type="vertical"),
)
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.