Skip to content

Lidar

Classified point-cloud heights and vegetation clearance around power lines

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/lidar/index.md to help me query Lidar 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.

Measure point heights above the ground

Uses the connector’s bundled synthetic point cloud and sample site geometry.

Example output · captured
Connector release
v0.3.0
Engine
2.0.1
VGI protocol
3.4.0
WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))) SELECT feature_id, round(building_p95_m, 1), canopy_max_m
FROM lidar.main.height_metrics((SELECT * FROM site))
ORDER BY feature_id
Result
feature_id round(building_p95_m, 1) canopy_max_m
site 11.9 18

Quick start

Choose where to run Lidar, 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 'lidar' AS lidar (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-lidar-worker'
);

3. Run a query

query.sql
WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))) SELECT feature_id, round(building_p95_m, 1), canopy_max_m
FROM lidar.main.height_metrics((SELECT * FROM site))
ORDER BY feature_id
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 'lidar' AS lidar (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-lidar-worker'
);

Overview

Airborne LiDAR analysis over classified LAS/LAZ point clouds: building and tree-canopy heights within polygons, and vegetation encroaching on power lines within a 3D clearance distance. Uses the cloud's existing ASPRS classes; a sample point cloud is included.

Catalog

Everything lidar exposes once attached — read straight from the worker's released build.

lidar 1 schema
main 2 functions

Spatial functions for lidar analysis.

Schema examples (4)
Examples (4)

Estimate heights above a known flat ground surface

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))) SELECT feature_id, round(building_p95_m, 1), canopy_max_m
FROM lidar.main.height_metrics((SELECT * FROM site))
ORDER BY feature_id;
Result
feature_id round(building_p95_m, 1) canopy_max_m
site 11.9 18

Run height_metrics twice over the bundled site, at the default 2 m and at a 15 m canopy threshold, and join the results: canopy cover is 0.077 and 0.038, so half of the canopy cells hold vegetation at least 15 m tall

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), any_canopy AS (SELECT feature_id, canopy_cover_fraction AS cover_2m FROM lidar.main.height_metrics((SELECT * FROM site))), tall AS (SELECT feature_id, canopy_cover_fraction AS cover_15m FROM lidar.main.height_metrics((SELECT * FROM site), canopy_height_m := 15)) SELECT feature_id, round(cover_2m, 3) AS cover_2m, round(cover_15m, 3) AS cover_15m, round(cover_15m / cover_2m, 2) AS tall_share
FROM any_canopy
JOIN tall USING (feature_id)
ORDER BY feature_id;

Find a tree return two metres below a conductor

WITH conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))) SELECT feature_id, round(clearance_m, 2)
FROM lidar.main.vegetation_clearance((SELECT * FROM conductor))
ORDER BY feature_id, point_index;

Span vegetation report: join canopy height and cover from height_metrics over the right-of-way polygon with vegetation_clearance returns along the conductor (12 m search); Span 7 has 18 m canopy, one return within 3 m, two within 12 m, the closest at 2 m

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))), spans(span_id, corridor_id, conductor_id) AS (VALUES ('Span 7', 'site', 'line')), canopy AS (SELECT feature_id, canopy_max_m, canopy_cover_fraction FROM lidar.main.height_metrics((SELECT * FROM site))), returns AS (SELECT feature_id, count(*) FILTER (WHERE clearance_m <= 3) AS within_3m, count(*) AS within_12m, min(clearance_m) AS closest_m FROM lidar.main.vegetation_clearance((SELECT * FROM conductor), clearance_m := 12) GROUP BY feature_id) SELECT s.span_id, c.canopy_max_m, round(c.canopy_cover_fraction, 3) AS canopy_cover, coalesce(r.within_3m, 0) AS within_3m, coalesce(r.within_12m, 0) AS within_12m, round(r.closest_m, 2) AS closest_m
FROM spans s
JOIN canopy c ON c.feature_id = s.corridor_id
LEFT JOIN returns r ON r.feature_id = s.conductor_id
ORDER BY s.span_id;
Table in-out functions
height_metrics (data TABLE, canopy_height_m := DOUBLE, clearance_m := DOUBLE, cloud_crs := VARCHAR, geometry_crs := VARCHAR, grid_size_m := DOUBLE, ground_radius_m := DOUBLE, max_distance_evaluations := BIGINT, max_grid_cells := BIGINT, max_points := BIGINT, max_segments := BIGINT, path := VARCHAR, z_scale_to_m := DOUBLE) 2 examples

Estimate building and canopy heights from classified LAS/LAZ points

Positional arguments
data TABLE
Rows with feature_id and geometry_wkb, as polygons for heights or 3D lines for clearance.
Named arguments
canopy_height_m := DOUBLE
Minimum supported vegetation height counted in canopy cells. · default 2.0
clearance_m := DOUBLE
Return vegetation points at or below this 3D conductor distance, metres. · default 3.0
cloud_crs := VARCHAR
Optional explicit CRS if LAS metadata are absent; otherwise use the LAS CRS. Must be projected in metres. · default ""
geometry_crs := VARCHAR
CRS for input WKB XY coordinates; conductor Z values must already be in metres in the cloud's vertical datum. · default "EPSG:32618"
grid_size_m := DOUBLE
Grid cell size for sampled canopy cover, metres. · default 5.0
ground_radius_m := DOUBLE
Maximum distance to the nearest class-2 ground return for height estimates. · default 25.0
max_distance_evaluations := BIGINT
Maximum candidate-point times segment evaluations per conductor. · default 50000000
max_grid_cells := BIGINT
Maximum canopy grid cells per polygon. · default 100000
max_points := BIGINT
Maximum cloud point count; oversized tiles fail before loading. · default 2000000
max_segments := BIGINT
Maximum segments in one conductor geometry. · default 10000
path := VARCHAR
Local LAS/LAZ file; original ASPRS classifications are required. · default "demo://classified.laz"
z_scale_to_m := DOUBLE
Multiplier converting LAS Z values to metres; this does not perform a vertical datum transformation. · default 1.0
Returns columns
feature_id VARCHAR
Caller-owned polygon identity.
point_count BIGINT
Number of non-noise points inside the polygon.
building_points BIGINT
Class-6 points with nearby classified ground support.
building_p95_m DOUBLE
95th percentile building height above nearest classified ground, metres.
building_max_m DOUBLE
Maximum supported building height above nearest ground, metres.
vegetation_points BIGINT
Class-3/4/5 points with nearby classified ground support.
canopy_p95_m DOUBLE
95th percentile supported vegetation height above ground, metres.
canopy_max_m DOUBLE
Maximum supported vegetation height above ground, metres.
canopy_cover_fraction DOUBLE
Fraction of fully ground-supported observed cells containing vegetation above canopy_height_m.
observed_cell_fraction DOUBLE
Fraction of polygon-intersecting grid cells with at least one usable point.
ground_supported_cell_fraction DOUBLE
Share of observed cells whose points all have ground support; denominator for canopy coverage.
unsupported_points BIGINT
Building/vegetation points without ground within ground_radius_m.
status VARCHAR
ok, partial_ground, no_ground, or no_points.
cloud_crs VARCHAR
Projected metre CRS of the source cloud.
Examples (2)

Estimate heights above a known flat ground surface

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))) SELECT feature_id, round(building_p95_m, 1), canopy_max_m
FROM lidar.main.height_metrics((SELECT * FROM site))
ORDER BY feature_id;
Result
feature_id round(building_p95_m, 1) canopy_max_m
site 11.9 18

Run height_metrics twice over the bundled site, at the default 2 m and at a 15 m canopy threshold, and join the results: canopy cover is 0.077 and 0.038, so half of the canopy cells hold vegetation at least 15 m tall

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), any_canopy AS (SELECT feature_id, canopy_cover_fraction AS cover_2m FROM lidar.main.height_metrics((SELECT * FROM site))), tall AS (SELECT feature_id, canopy_cover_fraction AS cover_15m FROM lidar.main.height_metrics((SELECT * FROM site), canopy_height_m := 15)) SELECT feature_id, round(cover_2m, 3) AS cover_2m, round(cover_15m, 3) AS cover_15m, round(cover_15m / cover_2m, 2) AS tall_share
FROM any_canopy
JOIN tall USING (feature_id)
ORDER BY feature_id;
Link
vegetation_clearance (data TABLE, canopy_height_m := DOUBLE, clearance_m := DOUBLE, cloud_crs := VARCHAR, geometry_crs := VARCHAR, grid_size_m := DOUBLE, ground_radius_m := DOUBLE, max_distance_evaluations := BIGINT, max_grid_cells := BIGINT, max_points := BIGINT, max_segments := BIGINT, path := VARCHAR, z_scale_to_m := DOUBLE) 2 examples

Find classified vegetation within a 3D power-line clearance distance

Positional arguments
data TABLE
Rows with feature_id and geometry_wkb, as polygons for heights or 3D lines for clearance.
Named arguments
canopy_height_m := DOUBLE
Minimum supported vegetation height counted in canopy cells. · default 2.0
clearance_m := DOUBLE
Return vegetation points at or below this 3D conductor distance, metres. · default 3.0
cloud_crs := VARCHAR
Optional explicit CRS if LAS metadata are absent; otherwise use the LAS CRS. Must be projected in metres. · default ""
geometry_crs := VARCHAR
CRS for input WKB XY coordinates; conductor Z values must already be in metres in the cloud's vertical datum. · default "EPSG:32618"
grid_size_m := DOUBLE
Grid cell size for sampled canopy cover, metres. · default 5.0
ground_radius_m := DOUBLE
Maximum distance to the nearest class-2 ground return for height estimates. · default 25.0
max_distance_evaluations := BIGINT
Maximum candidate-point times segment evaluations per conductor. · default 50000000
max_grid_cells := BIGINT
Maximum canopy grid cells per polygon. · default 100000
max_points := BIGINT
Maximum cloud point count; oversized tiles fail before loading. · default 2000000
max_segments := BIGINT
Maximum segments in one conductor geometry. · default 10000
path := VARCHAR
Local LAS/LAZ file; original ASPRS classifications are required. · default "demo://classified.laz"
z_scale_to_m := DOUBLE
Multiplier converting LAS Z values to metres; this does not perform a vertical datum transformation. · default 1.0
Returns columns
feature_id VARCHAR
Caller-owned conductor identity.
point_index BIGINT
Zero-based original point-cloud record index.
clearance_m DOUBLE
Exact Euclidean 3D distance from vegetation return to the nearest conductor segment, metres.
x DOUBLE
Vegetation return X in cloud_crs.
y DOUBLE
Vegetation return Y in cloud_crs.
z_m DOUBLE
Vegetation return elevation in metres in the supplied vertical datum.
nearest_x DOUBLE
Nearest conductor position X in cloud_crs.
nearest_y DOUBLE
Nearest conductor position Y in cloud_crs.
nearest_z_m DOUBLE
Nearest conductor elevation, metres in the same vertical datum as the cloud.
cloud_crs VARCHAR
Projected metre CRS for XY coordinates.
Examples (2)

Find a tree return two metres below a conductor

WITH conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))) SELECT feature_id, round(clearance_m, 2)
FROM lidar.main.vegetation_clearance((SELECT * FROM conductor))
ORDER BY feature_id, point_index;

Span vegetation report: join canopy height and cover from height_metrics over the right-of-way polygon with vegetation_clearance returns along the conductor (12 m search); Span 7 has 18 m canopy, one return within 3 m, two within 12 m, the closest at 2 m

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))), spans(span_id, corridor_id, conductor_id) AS (VALUES ('Span 7', 'site', 'line')), canopy AS (SELECT feature_id, canopy_max_m, canopy_cover_fraction FROM lidar.main.height_metrics((SELECT * FROM site))), returns AS (SELECT feature_id, count(*) FILTER (WHERE clearance_m <= 3) AS within_3m, count(*) AS within_12m, min(clearance_m) AS closest_m FROM lidar.main.vegetation_clearance((SELECT * FROM conductor), clearance_m := 12) GROUP BY feature_id) SELECT s.span_id, c.canopy_max_m, round(c.canopy_cover_fraction, 3) AS canopy_cover, coalesce(r.within_3m, 0) AS within_3m, coalesce(r.within_12m, 0) AS within_12m, round(r.closest_m, 2) AS closest_m
FROM spans s
JOIN canopy c ON c.feature_id = s.corridor_id
LEFT JOIN returns r ON r.feature_id = s.conductor_id
ORDER BY s.span_id;
Link

Try these queries

Run height_metrics twice over the bundled site, at the default 2 m and at a 15 m canopy threshold, and join the results: canopy cover is 0.077 and 0.038, so half of the canopy cells hold vegetation at least 15 m tall

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), any_canopy AS (SELECT feature_id, canopy_cover_fraction AS cover_2m FROM lidar.main.height_metrics((SELECT * FROM site))), tall AS (SELECT feature_id, canopy_cover_fraction AS cover_15m FROM lidar.main.height_metrics((SELECT * FROM site), canopy_height_m := 15)) SELECT feature_id, round(cover_2m, 3) AS cover_2m, round(cover_15m, 3) AS cover_15m, round(cover_15m / cover_2m, 2) AS tall_share
FROM any_canopy
JOIN tall USING (feature_id)
ORDER BY feature_id

Uses height_metrics

Find a tree return two metres below a conductor

WITH conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))) SELECT feature_id, round(clearance_m, 2)
FROM lidar.main.vegetation_clearance((SELECT * FROM conductor))
ORDER BY feature_id, point_index

Uses vegetation_clearance

Span vegetation report: join canopy height and cover from height_metrics over the right-of-way polygon with vegetation_clearance returns along the conductor (12 m search); Span 7 has 18 m canopy, one return within 3 m, two within 12 m, the closest at 2 m

WITH site(feature_id, geometry_wkb) AS (VALUES ('site', ST_AsWKB('POLYGON ((499995 4099995, 500045 4099995, 500045 4100045, 499995 4100045, 499995 4099995))'::GEOMETRY))), conductor(feature_id, geometry_wkb) AS (VALUES ('line', ST_AsWKB('LINESTRING Z (500025 4100030 120, 500040 4100030 120)'::GEOMETRY))), spans(span_id, corridor_id, conductor_id) AS (VALUES ('Span 7', 'site', 'line')), canopy AS (SELECT feature_id, canopy_max_m, canopy_cover_fraction FROM lidar.main.height_metrics((SELECT * FROM site))), returns AS (SELECT feature_id, count(*) FILTER (WHERE clearance_m <= 3) AS within_3m, count(*) AS within_12m, min(clearance_m) AS closest_m FROM lidar.main.vegetation_clearance((SELECT * FROM conductor), clearance_m := 12) GROUP BY feature_id) SELECT s.span_id, c.canopy_max_m, round(c.canopy_cover_fraction, 3) AS canopy_cover, coalesce(r.within_3m, 0) AS within_3m, coalesce(r.within_12m, 0) AS within_12m, round(r.closest_m, 2) AS closest_m
FROM spans s
JOIN canopy c ON c.feature_id = s.corridor_id
LEFT JOIN returns r ON r.feature_id = s.conductor_id
ORDER BY s.span_id

Uses height_metricsvegetation_clearance

Lidar 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.