Skip to content

Earth observation

Optical index and calibrated radar histories for geospatial SQL queries

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/earth-observation/index.md to help me query Earth observation with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find vegetation declines in two synthetic parcels

Example output Β· captured
Connector release
v0.3.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT parcel_id, round(mean_index, 2), decline
FROM earth_observation.main.parcel_series((SELECT * FROM earth_observation.main.sample_parcels))
ORDER BY parcel_id, observed_at
Result
parcel_id round(mean_index, 2) decline
field-a 0.6 NULL
field-a 0 true
field-b 0.6 NULL
field-b 0 true

Quick start

Choose where to run Earth observation, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
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;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'earth_observation' AS earth_observation (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-earth-observation-worker'
);

3. Run a query

query.sql
SELECT parcel_id, round(mean_index, 2), decline
FROM earth_observation.main.parcel_series((SELECT * FROM earth_observation.main.sample_parcels))
ORDER BY parcel_id, observed_at
More example queries β†’
Technical details
Verified connector release
v0.3.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'earth_observation' AS earth_observation (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-earth-observation-worker'
);

Overview

Satellite imagery histories for land parcels and regions from STAC catalogs: cloud-masked Sentinel-2 vegetation and water indices and calibrated Sentinel-1 radar backscatter, with change flags. Reads local STAC files or public STAC APIs; offline sample scenes are included.

Catalog

Everything earth_observation exposes once attached β€” read straight from the worker's released build.

earth_observation 1 schema
main 1 table Β· 2 functions

Spatial functions and bundled inputs for earth observation analysis.

Schema examples (5)
Examples (5)

List the bundled parcel IDs

SELECT parcel_id
FROM earth_observation.main.sample_parcels
ORDER BY parcel_id;

Find vegetation declines in two synthetic parcels

SELECT parcel_id, round(mean_index, 2), decline
FROM earth_observation.main.parcel_series((SELECT * FROM earth_observation.main.sample_parcels))
ORDER BY parcel_id, observed_at;
Result
parcel_id round(mean_index, 2) decline
field-a 0.6 NULL
field-a 0 true
field-b 0.6 NULL
field-b 0 true

Per parcel, join the count of optical NDVI declines and the worst NDVI change to the VV backscatter change in dB between the first and last fully covered radar acquisitions on each orbit track

WITH optical AS (SELECT parcel_id, count(*) FILTER (WHERE decline) AS ndvi_declines, min(delta_index) AS worst_ndvi_change FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) GROUP BY parcel_id), radar AS (SELECT region_id, relative_orbit, orbit_state, arg_max(mean_db, observed_at) - arg_min(mean_db, observed_at) AS vv_change_db FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels), polarizations := 'vv') WHERE status = 'ok' GROUP BY region_id, relative_orbit, orbit_state) SELECT o.parcel_id, o.ndvi_declines, round(o.worst_ndvi_change, 2) AS worst_ndvi_change, r.relative_orbit, r.orbit_state, round(r.vv_change_db, 1) AS vv_change_db
FROM optical AS o
JOIN radar AS r ON r.region_id = o.parcel_id
ORDER BY o.parcel_id, r.relative_orbit, r.orbit_state;

Inspect a synthetic radar-return decrease and an explicit missing observation

SELECT observed_at::DATE AS observed_date, round(mean_db, 1), status
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id='field-a'), polarizations := 'vv')
ORDER BY observed_at;
1 more example

Follow up parcels flagged with an optical NDVI decline: VV minus VH backscatter in dB for each fully covered radar acquisition

WITH declined AS (SELECT DISTINCT parcel_id FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) WHERE decline) SELECT region_id, observed_at::DATE AS observed_date, relative_orbit, round(max(mean_db) FILTER (WHERE polarization = 'VV') - max(mean_db) FILTER (WHERE polarization = 'VH'), 1) AS vv_minus_vh_db
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id IN (SELECT parcel_id FROM declined)))
WHERE status = 'ok'
GROUP BY region_id, observed_at, relative_orbit
ORDER BY region_id, observed_at;
Tables
sample_parcels 1 example2 cols

Two synthetic agricultural parcels matching the bundled offline satellite scenes

Columns
parcel_idnot null VARCHAR
Caller-owned parcel identity.
geometry_wkb BLOB
Polygon WKB in geometry_crs.
ConstraintsPRIMARY KEY (parcel_id)
Example

List the bundled parcel IDs

SELECT parcel_id
FROM earth_observation.main.sample_parcels
ORDER BY parcel_id;
Link
Table in-out functions
parcel_series (data TABLE, catalog := VARCHAR, clear_scl_classes := VARCHAR, collections := VARCHAR, composite := VARCHAR, decline_threshold := DOUBLE, end_date := VARCHAR, geometry_crs := VARCHAR, green_asset := VARCHAR, index_name := VARCHAR, max_change_gap_days := DOUBLE, max_cloud := DOUBLE, max_json_bytes := BIGINT, max_pages := BIGINT, max_pixels := BIGINT, max_scenes := BIGINT, max_source_pixels := BIGINT, min_coverage := DOUBLE, nir_asset := VARCHAR, offset_mode := VARCHAR, red_asset := VARCHAR, scl_asset := VARCHAR, start_date := VARCHAR, swir_asset := VARCHAR) 2 examples

Cloud-mask and align satellite bands into parcel index histories and decline flags

Positional arguments
data TABLE
Rows with parcel_id and polygon geometry_wkb; NULL/invalid geometries fail.
Named arguments
catalog := VARCHAR
STAC ItemCollection JSON path/URL or public API root with a search link. Β· default "demo://scenes.json"
clear_scl_classes := VARCHAR
Comma-separated SCL codes treated as clear; default vegetation, bare soil, and water. Β· default "4,5,6"
collections := VARCHAR
Comma-separated collection IDs for STAC API search. Β· default "sentinel-2-l2a"
composite := VARCHAR
Monthly pixel-median composites or individual observation-time composites. Β· default "month"
decline_threshold := DOUBLE
Minimum absolute negative index change to flag as a decline. Β· default 0.3
end_date := VARCHAR
Inclusive UTC ISO observation end. Β· default "2026-12-31T23:59:59Z"
geometry_crs := VARCHAR
Explicit CRS of all input parcel WKB geometries; XY axis order. Β· default "EPSG:32618"
green_asset := VARCHAR
STAC asset key for green reflectance when computing NDWI. Β· default "green"
index_name := VARCHAR
Normalized difference: NDVI=(NIR-red)/(NIR+red), NDWI=(green-NIR)/(green+NIR), NBR=(NIR-SWIR)/(NIR+SWIR). Β· default "ndvi"
max_change_gap_days := DOUBLE
Maximum time separation between change-comparison observations. Β· default 90.0
max_cloud := DOUBLE
Maximum scene-level cloud percentage; pixel cloud masks are still applied. Β· default 100.0
max_json_bytes := BIGINT
Maximum decoded bytes per STAC JSON page or static document. Β· default 16777216
max_pages := BIGINT
Hard STAC pagination bound; cyclic or excessive paging fails. Β· default 100
max_pixels := BIGINT
Maximum aligned bounding-window pixels per parcel; a 20 million pixel-scene memory cap also applies. Β· default 1000000
max_scenes := BIGINT
Hard scene limit; an oversized result fails instead of silently truncating. Β· default 128
max_source_pixels := BIGINT
Maximum native pixels per reflectance crop before cloud masking and resampling. Β· default 4000000
min_coverage := DOUBLE
Minimum clear pixel fraction before a result participates in change detection. Β· default 0.5
nir_asset := VARCHAR
STAC asset key for near-infrared reflectance. Β· default "nir08"
offset_mode := VARCHAR
auto honors Earth Search's already-applied BOA flag for GeoTIFF assets, otherwise uses band metadata. metadata always applies declared offsets; zero ignores offsets for independently verified harmonized data. Effective calibration is returned for audit. Β· default "auto"
red_asset := VARCHAR
STAC asset key for red reflectance. Β· default "red"
scl_asset := VARCHAR
Required categorical Scene Classification Layer asset; never bilinearly resampled. Β· default "scl"
start_date := VARCHAR
Inclusive UTC ISO observation start. Β· default "2026-01-01T00:00:00Z"
swir_asset := VARCHAR
STAC asset key for shortwave infrared reflectance when computing NBR. Β· default "swir22"
Returns columns
parcel_id VARCHAR
Input parcel ID for joins to ownership and weather.
observed_at TIMESTAMP
UTC observation time, or first day of the month for monthly composites.
index_name VARCHAR
ndvi, ndwi, or nbr.
mean_index DOUBLE
Mean of valid pixel indices, after cloud masking and optional pixel-median compositing.
valid_pixels BIGINT
Valid, cloud-free polygon pixels in the aligned grid.
total_pixels BIGINT
Grid pixel centres inside the polygon, including cloudy and missing cells.
coverage_fraction DOUBLE
Valid pixels divided by total polygon pixels.
delta_index DOUBLE
Change from the previous adequately observed result within max_change_gap_days.
decline BOOLEAN
True when delta_index is at most negative decline_threshold; NULL without a valid comparison.
scene_count BIGINT
Number of contributing candidate scenes in this observation or composite.
scene_ids VARCHAR
JSON array of source scene identifiers for provenance.
calibration VARCHAR
JSON per scene and band: effective reflectance scale, offset and source.
status VARCHAR
ok, insufficient_coverage, or no_scenes; missing coverage never becomes a zero index.
analysis_crs VARCHAR
CRS of the first selected denominator-band grid, used for all aligned bands.
Examples (2)

Find vegetation declines in two synthetic parcels

SELECT parcel_id, round(mean_index, 2), decline
FROM earth_observation.main.parcel_series((SELECT * FROM earth_observation.main.sample_parcels))
ORDER BY parcel_id, observed_at;
Result
parcel_id round(mean_index, 2) decline
field-a 0.6 NULL
field-a 0 true
field-b 0.6 NULL
field-b 0 true

Per parcel, join the count of optical NDVI declines and the worst NDVI change to the VV backscatter change in dB between the first and last fully covered radar acquisitions on each orbit track

WITH optical AS (SELECT parcel_id, count(*) FILTER (WHERE decline) AS ndvi_declines, min(delta_index) AS worst_ndvi_change FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) GROUP BY parcel_id), radar AS (SELECT region_id, relative_orbit, orbit_state, arg_max(mean_db, observed_at) - arg_min(mean_db, observed_at) AS vv_change_db FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels), polarizations := 'vv') WHERE status = 'ok' GROUP BY region_id, relative_orbit, orbit_state) SELECT o.parcel_id, o.ndvi_declines, round(o.worst_ndvi_change, 2) AS worst_ndvi_change, r.relative_orbit, r.orbit_state, round(r.vv_change_db, 1) AS vv_change_db
FROM optical AS o
JOIN radar AS r ON r.region_id = o.parcel_id
ORDER BY o.parcel_id, r.relative_orbit, r.orbit_state;
Link
radar_series (regions TABLE, catalog := VARCHAR, collections := VARCHAR, end_date := VARCHAR, geometry_crs := VARCHAR, max_json_bytes := BIGINT, max_pages := BIGINT, max_pixels := BIGINT, max_scenes := BIGINT, min_coverage := DOUBLE, polarizations := VARCHAR, start_date := VARCHAR, value_unit := VARCHAR) 2 examples

Summarize calibrated SAR backscatter by region, acquisition, viewing track and polarization

Positional arguments
regions TABLE
Relation with region_id and polygon geometry_wkb columns.
Named arguments
catalog := VARCHAR
Local STAC items or public API root. Β· default "demo://radar-scenes.json"
collections := VARCHAR
Comma-separated STAC collection names for API search. Β· default "sentinel-1-rtc"
end_date := VARCHAR
Inclusive UTC acquisition upper bound, ISO 8601. Β· default "2025-12-31T23:59:59Z"
geometry_crs := VARCHAR
Explicit CRS of input polygon WKB. Β· default "EPSG:32618"
max_json_bytes := BIGINT
Maximum bytes per STAC page or local document. Β· default 16777216
max_pages := BIGINT
Hard STAC pagination bound. Β· default 100
max_pixels := BIGINT
Hard native bounding-window pixel limit for each region. Β· default 1000000
max_scenes := BIGINT
Hard scene bound; excess results fail without truncation. Β· default 128
min_coverage := DOUBLE
Minimum valid fraction to return a mean measurement. Β· default 0.9
polarizations := VARCHAR
Required polarization asset keys; missing assets fail. Β· default "vv,vh"
start_date := VARCHAR
Inclusive UTC acquisition lower bound, ISO 8601. Β· default "2025-01-01"
value_unit := VARCHAR
Calibrated source unit after band scale/offset; db is converted to linear power before averaging. Β· default "linear_power"
Returns columns
region_id VARCHAR
Caller-owned region identity for joins.
observed_at TIMESTAMP
UTC acquisition instant; NULL when no scenes match.
scene_id VARCHAR
STAC scene identifier; overlapping acquisitions must not be counted as independent.
platform VARCHAR
Satellite identity normalized to lowercase; different satellites remain separate.
relative_orbit BIGINT
Repeat ground-track identifier; compare within this orbit only.
orbit_state VARCHAR
Ascending or descending pass direction.
polarization VARCHAR
VV or VH measurement channel.
mean_power DOUBLE
Arithmetic spatial mean calibrated linear radar power.
mean_db DOUBLE
10*log10(mean_power), not the spatial mean of pixel dB values.
valid_pixels BIGINT
Finite usable pixels whose centres lie in the region.
total_pixels BIGINT
All region pixel centres, including nodata and cells outside raster coverage.
coverage_fraction DOUBLE
Usable region pixels divided by total region pixels.
grid_crs VARCHAR
Native projected raster CRS with metre units.
pixel_width_m DOUBLE
Raster grid spacing in metres; not necessarily sensor resolving power.
pixel_height_m DOUBLE
Raster grid spacing in metres; not necessarily sensor resolving power.
status VARCHAR
ok, insufficient_coverage, no_pixel_centres, or no_scenes.
Examples (2)

Inspect a synthetic radar-return decrease and an explicit missing observation

SELECT observed_at::DATE AS observed_date, round(mean_db, 1), status
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id='field-a'), polarizations := 'vv')
ORDER BY observed_at;

Follow up parcels flagged with an optical NDVI decline: VV minus VH backscatter in dB for each fully covered radar acquisition

WITH declined AS (SELECT DISTINCT parcel_id FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) WHERE decline) SELECT region_id, observed_at::DATE AS observed_date, relative_orbit, round(max(mean_db) FILTER (WHERE polarization = 'VV') - max(mean_db) FILTER (WHERE polarization = 'VH'), 1) AS vv_minus_vh_db
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id IN (SELECT parcel_id FROM declined)))
WHERE status = 'ok'
GROUP BY region_id, observed_at, relative_orbit
ORDER BY region_id, observed_at;
Link

Try these queries

List the bundled parcel IDs

SELECT parcel_id
FROM earth_observation.main.sample_parcels
ORDER BY parcel_id

Uses sample_parcels

Per parcel, join the count of optical NDVI declines and the worst NDVI change to the VV backscatter change in dB between the first and last fully covered radar acquisitions on each orbit track

WITH optical AS (SELECT parcel_id, count(*) FILTER (WHERE decline) AS ndvi_declines, min(delta_index) AS worst_ndvi_change FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) GROUP BY parcel_id), radar AS (SELECT region_id, relative_orbit, orbit_state, arg_max(mean_db, observed_at) - arg_min(mean_db, observed_at) AS vv_change_db FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels), polarizations := 'vv') WHERE status = 'ok' GROUP BY region_id, relative_orbit, orbit_state) SELECT o.parcel_id, o.ndvi_declines, round(o.worst_ndvi_change, 2) AS worst_ndvi_change, r.relative_orbit, r.orbit_state, round(r.vv_change_db, 1) AS vv_change_db
FROM optical AS o
JOIN radar AS r ON r.region_id = o.parcel_id
ORDER BY o.parcel_id, r.relative_orbit, r.orbit_state

Uses parcel_seriessample_parcelsradar_series

Inspect a synthetic radar-return decrease and an explicit missing observation

SELECT observed_at::DATE AS observed_date, round(mean_db, 1), status
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id='field-a'), polarizations := 'vv')
ORDER BY observed_at

Uses radar_seriessample_parcels

Follow up parcels flagged with an optical NDVI decline: VV minus VH backscatter in dB for each fully covered radar acquisition

WITH declined AS (SELECT DISTINCT parcel_id FROM earth_observation.main.parcel_series((SELECT parcel_id, geometry_wkb FROM earth_observation.main.sample_parcels)) WHERE decline) SELECT region_id, observed_at::DATE AS observed_date, relative_orbit, round(max(mean_db) FILTER (WHERE polarization = 'VV') - max(mean_db) FILTER (WHERE polarization = 'VH'), 1) AS vv_minus_vh_db
FROM earth_observation.main.radar_series((SELECT parcel_id AS region_id, geometry_wkb FROM earth_observation.main.sample_parcels WHERE parcel_id IN (SELECT parcel_id FROM declined)))
WHERE status = 'ok'
GROUP BY region_id, observed_at, relative_orbit
ORDER BY region_id, observed_at

Uses parcel_seriessample_parcelsradar_series

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • List the bundled parcel IDs. Use the bundled synthetic inputs and return the columns and ordering shown in its catalog example.
  • Find vegetation declines in two synthetic parcels. Use the bundled synthetic inputs and return the columns and ordering shown in its catalog example.

Earth observation is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.