Skip to content

v0.1.0

Choose a tag to compare

@rustyconover rustyconover released this 14 Nov 16:39
· 10 commits to main since this release

First release of vgi-pysal, a VGI worker that brings PySAL (the Python Spatial Analysis Library) to DuckDB / Haybarn 2.0. It lets you build spatial weights, measure spatial autocorrelation (Moran's I, Geary's C, Getis-Ord, LISA), classify choropleth maps, compute inequality indices and fit spatial regressions, all from SQL. Speaks VGI protocol 3.3 (vgi-python 0.51.1).

Functions

Function Kind Purpose
columbus, baltim, sids, us_states, mexico, georgia table Built-in example datasets
weights / weights_summary table Neighbour graph as an edge list / connectivity diagnostics
moran, geary, getis_ord_g table Global spatial autocorrelation
local_moran, getis_ord_g_local table Local autocorrelation and hot spots, one row per observation
quantiles, equal_interval, natural_breaks, fisher_jenks, std_mean, box_plot, head_tail_breaks table Choropleth classification
gini, theil aggregate Inequality indices
spreg table Spatial regression coefficient table
fit / predict table Fit and store a model, then score rows with it
list_models, model_info, drop_model table Model registry

Composed examples

These ship in the catalog metadata (vgi.example_queries and the driving functions' example lists). All of them run on built-in data:

  • Spatial lag of crime: join the queen weights edge list to columbus and average each neighbourhood's neighbours' crime.
  • LISA cluster profile: join local_moran back to columbus and compare crime, income and house value per cluster type.
  • Crime by income quintile: classify income with quantiles, then aggregate crime for each class.

The release also includes agent test tasks that graders check against fixed, seeded built-in data.

Quick start

The worker isn't on PyPI. uvx runs it from this tag:

INSTALL vgi FROM community;
LOAD vgi;

ATTACH 'pysal' AS pysal (TYPE vgi, LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-pysal@v0.1.0 vgi-pysal');

SELECT statistic AS morans_i, p_value
FROM pysal.moran((SELECT crime AS y, geom FROM pysal.columbus()), w_type => 'queen');

Or use the signed multi-arch image: LOCATION 'docker://ghcr.io/query-farm/vgi-pysal:0.1.0'.

Known limits

  • Choice arguments (w_type, kernel_function, model) are case-sensitive at bind time. Use 'queen', not 'Queen'.
  • Stored models go to local disk (PYSAL_MODELS_DIR, default ./models) as plain JSON. The examples for list_models / model_info depend on a model that fit has stored first.
  • The geopandas/scipy stack is heavy, so the first uvx ATTACH takes a while to build the environment.
  • This is a source-only release with no binary assets. The container image is ghcr.io/query-farm/vgi-pysal:0.1.0.