Skip to content

v0.1.0

Choose a tag to compare

@github-actions github-actions released this 14 Nov 16:25
· 14 commits to main since this release

First release of vgi-trajectory, a Python VGI worker that turns GPS fixes into visits, trips and gaps from SQL.

It reconstructs each entity's track by linear interpolation, intersects straight segments with geofence boundaries to infer entry/exit times (a visit can contain zero recorded fixes), and marks long gaps, implausible speeds and low-accuracy segments as unknown movement instead of inventing visits.

Functions and tables

  • trajectory.main.episodes((SELECT entity_id, observed_at, x, y FROM fixes), ...): returns visit, trip and gap episodes with timestamps, dwell duration, distance, fix count, interpolated-boundary flags, left/right censoring and WKB paths. Options include fences (local GeoJSON), input_crs, fence_crs, analysis_crs, max_gap_s, min_dwell_s and an optional accuracy_m input column.
  • trajectory.main.demo_input: two synthetic tracks (crossing, stopped) with a bundled synthetic fence, so it runs without data credentials.

Composed examples

  • ASOF-join each visit back to the last demo_input fix at or before entry. The crossing entity enters the yard 30 s after its last fix with no fixes inside.
  • Each entity's visit share of its observed span (0.5 and 1.0 on the demo data).
  • Agent tasks gis_gap_sensitivity (compares two episodes runs with different max_gap_s) and gis_trip_distance_and_fixes (episodes joined to demo_input fix counts).

Install

Requires Python 3.13+ and uv.

git clone --branch v0.1.0 https://github.com/Query-farm/vgi-trajectory
cd vgi-trajectory
uv sync --locked
make demo
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL spatial;
LOAD spatial;
ATTACH 'trajectory' (TYPE vgi,
  LOCATION '/absolute/path/to/vgi-trajectory/.venv/bin/vgi-trajectory-worker');

The wheel and sdist attached here are signed with cosign (keyless) and carry build provenance. This worker is not published to PyPI.

Known limits

  • Linear interpolation between fixes, not road map matching. Single fixes produce no episodes.
  • Defaults treat gaps over 900 s, speeds over 80 m/s or accuracy worse than 100 m as unknown movement. Gap rows have NULL path/distance.
  • Overlapping fences produce independent visits and can double-count time across fences.
  • Input is buffered per query (default cap: 1 million fixes). Conflicting locations at one timestamp fail.
  • Supply UTC timestamps, an explicit input CRS and a projected metre analysis_crs. WKB output is a plain BLOB with a companion CRS, not an automatically transformed geometry.
  • Targets vgi-python 0.51, VGI protocol 3.3 and DuckDB / Haybarn 2.0.