Skip to content

CSV Points and Histogram ​

Load a CSV with latitude and longitude columns via ak.latlng(), render points on a map, and link a histogram brush back to the map.

Python Script ​

python
"""CSV points + histogram — lat/lng points from CSV alongside a histogram of latitude."""
from __future__ import annotations

from pathlib import Path

import pyautark as ak

DATA_DIR = Path(__file__).resolve().parents[1] / "data"

trees = ak.CSV(
    "trees",
    url=(DATA_DIR / "trees.csv").as_uri(),
    geometry=ak.latlng("latitude", "longitude", coordinate_format="EPSG:4326"),
)

spec = ak.Spec(
    metadata=ak.Metadata(title="CSV Points + Histogram"),
    data=[trees],
    views=[
        ak.Map(
            camera=ak.Camera(zoom=13),
            layers=[
                ak.Layer(trees, id="trees_layer").style(
                    color="#27ae60", opacity=0.8
                )
            ],
        ),
        ak.Histogram(source=trees, x="latitude", bins=25),
    ],
    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.

Released under the MIT License.