DuckDB Extension
GeoSilo
Store compact geometry values with the GEOSILO type in DuckDB. Encode coordinates on insert and query them with geometry functions.
On this page
Sample data for the examples
Each browser example starts with these sample tables; sample files are shared across examples on this page. Run this setup first when trying the examples in your own DuckDB session.
-- check-fixtures.sql for geosilo
-- spatial is needed for ST_GeomFromText, ST_AsText, etc.
INSTALL spatial;
LOAD spatial;
-- raw GEOMETRY source for INSERT INTO parcels SELECT ... FROM raw_parcels;
CREATE OR REPLACE TABLE raw_parcels AS
SELECT * FROM (VALUES
(1, 'a', ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))')),
(2, 'b', ST_GeomFromText('POLYGON((2 2,3 2,3 3,2 3,2 2))'))
) t(id, name, geom);
-- roads(geom) for ST_Length aggregate
CREATE OR REPLACE TABLE roads AS
SELECT * FROM (VALUES
(ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2)')),
(ST_GeomFromText('LINESTRING(0 0, 0 1, 0 2)'))
) t(geom);
-- stations(id, geom) β point geometries for ST_X/ST_Y
CREATE OR REPLACE TABLE stations AS
SELECT * FROM (VALUES
(1, ST_GeomFromText('POINT(-77.0 39.0)')),
(2, ST_GeomFromText('POINT(-76.5 40.5)'))
) t(id, geom);
-- mixed_geom_table(geom) β mixed geometry types
CREATE OR REPLACE TABLE mixed_geom_table AS
SELECT * FROM (VALUES
(ST_GeomFromText('POINT(0 0)')),
(ST_GeomFromText('LINESTRING(0 0, 1 1)')),
(ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))'))
) t(geom);
-- compact_table(silo_blob) β geosilo blobs for geosilo_metadata example
CREATE OR REPLACE TABLE compact_table AS
SELECT geosilo_encode(ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))')) AS silo_blob
UNION ALL
SELECT geosilo_encode(ST_GeomFromText('POINT(1 2)')) AS silo_blob;
-- utm_data(geom) β projected meters geometry source
CREATE OR REPLACE TABLE utm_data AS
SELECT ST_GeomFromText('POINT(500000 4500000)') AS geom;
-- mm_precision_data(geom) and millimeter_data(geom)
CREATE OR REPLACE TABLE mm_precision_data AS
SELECT ST_GeomFromText('POINT(0.001 0.002)') AS geom;
CREATE OR REPLACE TABLE millimeter_data AS
SELECT ST_GeomFromText('POINT(0.001 0.002)') AS geom;
-- parcels_geometry(id, geom) β GEOMETRY-typed parcels for export example
CREATE OR REPLACE TABLE parcels_geometry AS
SELECT id, geom FROM raw_parcels;
-- parcels(id, name, geom GEOSILO) β the table the cookbook defines and fills
-- in earlier blocks. Each in-browser example runs on its own, so it needs to
-- exist up front. The polygons sit inside the cookbook's -78..-76 longitude,
-- 39..41 latitude band, so its bounding-box filters return rows.
CREATE OR REPLACE TABLE parcels (
id INTEGER,
name VARCHAR,
geom GEOSILO('EPSG:4326') USING COMPRESSION zstd
);
INSERT INTO parcels
SELECT * FROM (VALUES
(1, 'north lot', ST_GeomFromText('POLYGON((-77.2 39.8,-77.1 39.8,-77.1 39.9,-77.2 39.9,-77.2 39.8))')),
(2, 'river parcel', ST_GeomFromText('POLYGON((-76.9 40.1,-76.8 40.1,-76.8 40.2,-76.9 40.2,-76.9 40.1))')),
(3, 'west field', ST_GeomFromText('POLYGON((-79.5 38.0,-79.4 38.0,-79.4 38.1,-79.5 38.1,-79.5 38.0))'))
) t(id, name, geom);
-- Source table and input files the cookbook's load examples read.
CREATE OR REPLACE TABLE raw_data AS SELECT id, geom FROM raw_parcels;
COPY (SELECT id, name, ST_AsText(geom) AS wkt FROM raw_parcels)
TO 'parcels.csv' (HEADER true);
COPY (SELECT id, name, ST_AsWKB(geom) AS geom_wkb FROM raw_parcels)
TO 'parcels.parquet' (FORMAT PARQUET);
Store geometry with controlled coordinate precision
GeoSilo adds a compact geometry type that stores scaled integer coordinates and the differences between nearby vertices. You choose the coordinate scale, which determines the precision retained by the encoding.
Use it when storing large geometry datasets and controlling their size matters. The extension supplies native operations for its GEOSILO values and converts to GEOMETRY for other spatial operations. Check the precision and resulting storage size on your own data before adopting the format.
Example
Store and read a point
Load GeoSilo before spatial for compatibility with older builds. The sample supplies its own geometry and uses a temporary table.
Tested with DuckDB 1.5.6. Browser examples use Haybarn-Wasm 2.0.0-rc12.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL geosilo FROM query_farm;
LOAD geosilo FROM query_farm;
INSTALL spatial;
LOAD spatial;
CREATE OR REPLACE TEMP TABLE qf_points (
id INTEGER,
geom GEOSILO('EPSG:4326')
);
INSERT INTO qf_points VALUES (1, ST_Point(-74.0060, 40.7128));
SELECT id, ST_X(geom) AS longitude, ST_Y(geom) AS latitude
FROM qf_points;
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://haybarn-extensions.query.farm';
INSTALL geosilo FROM query_farm;
LOAD geosilo FROM query_farm;
INSTALL spatial;
LOAD spatial;
CREATE OR REPLACE TEMP TABLE qf_points (
id INTEGER,
geom GEOSILO('EPSG:4326')
);
INSERT INTO qf_points VALUES (1, ST_Point(-74.0060, 40.7128));
SELECT id, ST_X(geom) AS longitude, ST_Y(geom) AS latitude
FROM qf_points;
INSTALL geosilo FROM community;
LOAD geosilo;
INSTALL spatial;
LOAD spatial;
CREATE OR REPLACE TEMP TABLE qf_points (
id INTEGER,
geom GEOSILO('EPSG:4326')
);
INSERT INTO qf_points VALUES (1, ST_Point(-74.0060, 40.7128));
SELECT id, ST_X(geom) AS longitude, ST_Y(geom) AS latitude
FROM qf_points;
Expected result
| id | longitude | latitude |
|---|---|---|
| 1 | -74.006 | 40.7128 |
For persistent tables, see the compression and coordinate-scale guidance. The temporary table above demonstrates the type; it does not measure storage savings.
Common tasks
Deep Dive
Technical Details
These examples use DuckDB 2.0 or later. Complete the repository setup and installation first.
What you can do with one column type
The single most useful pattern: take an existing GEOMETRY column and re-declare it as GEOSILO with ZSTD compression. Every existing ST_* query still works β and the introspection / bounding-box / measurement calls get faster:
INSTALL geosilo FROM query_farm; LOAD geosilo FROM query_farm;INSTALL spatial; LOAD spatial;
-- Compact geometry, transparent ST_* surfaceCREATE OR REPLACE TABLE parcels ( id INTEGER, name VARCHAR, geom GEOSILO('EPSG:4326') USING COMPRESSION zstd);
INSERT INTO parcels SELECT id, name, geom FROM raw_parcels;
-- Bounding-box prefilter β entirely native, no WKB decodeSELECT id, ST_Area(geom)FROM parcelsWHERE ST_XMin(geom) > -78 AND ST_XMax(geom) < -76;The GEOSILO type delta-encodes coordinates as scaled integers β each subsequent vertex of a ring is a 2-byte int16 offset from the previous one. On the TIGER/Line 2025 US Census dataset, GEOSILO + ZSTD is ~21% smaller than DuckDBβs columnar GEOMETRY storage.
GeoSilo is a compact storage format with a handful of native ST_* overloads. It is not a re-implementation of GEOS. The native fast path covers exactly: ST_GeometryType, ST_IsEmpty, ST_NPoints, ST_X / ST_Y, ST_XMin / ST_XMax / ST_YMin / ST_YMax, ST_Area, ST_Length, ST_Perimeter. Everything else β ST_Buffer, ST_Union, ST_Intersection, ST_AsText, and the rest of the spatial extension surface β works via the implicit GEOSILO β GEOMETRY cast (which runs geosilo_decode under the hood).
The encoding is also lossy at the chosen integer scale. Defaults give ~1 cm precision; finer data needs an explicit geosilo_encode(geom, scale).
For unbounded GEOS-backed analytics, use spatial directly. For storage-heavy workflows where bounding-box filtering and area / length scans dominate, GeoSilo is the right tool.
Setup
Load spatial for geometry functions beyond GeoSiloβs native overloads. This order also works with older GeoSilo builds:
INSTALL geosilo FROM query_farm; LOAD geosilo FROM query_farm;INSTALL spatial; LOAD spatial;The v1.5 registration fix merges all 12 native ST_* overloads with Spatialβs existing functions, so either load order works in builds containing the fix. Older build d088741 fails with ST_GeometryType already exists when Spatial is loaded first; restart the connection and use the order above. Committing the fix does not change previously installed binaries.
The GEOSILO column type
Declare a column as GEOSILO, optionally tagging the CRS. With a CRS the integer scale is auto-detected (degrees β 1e7, meters β 100); without one, the default is 1e7:
-- With CRS β scale auto-detectedCREATE OR REPLACE TABLE parcels ( id INTEGER, name VARCHAR, geom GEOSILO('EPSG:4326') USING COMPRESSION zstd);-- Without CRS β default scale 1e7CREATE TABLE shapes (geom GEOSILO USING COMPRESSION zstd);USING COMPRESSION zstd is the recommended setting β itβs where the storage win comes from. See CREATE TABLE for the full DDL.
The implicit GEOMETRY β GEOSILO cast auto-encodes on insert, so you can populate from any GEOMETRY source β Parquet, CSV-then-ST_GeomFromText, another DuckDB table:
INSERT INTO parcels (id, geom) SELECT id, geom FROM raw_data;| Cast | Kind | Notes |
|---|---|---|
GEOMETRY β GEOSILO |
implicit | Encodes, with the scale taken from the CRS |
GEOSILO β GEOMETRY |
implicit | Runs geosilo_decode |
BLOB β GEOSILO |
explicit only | Validates the silo header; TRY_CAST returns NULL on a bad one. Use it on geosilo_encode output: geosilo_encode(geom)::GEOSILO |
GEOSILO β BLOB |
none |
Whatβs native, what auto-decodes
Standard spatial functions all work on GEOSILO columns. The ones below have native GEOSILO overloads that read the silo header or walk the integer delta stream β no WKB round-trip:
| Group | Native overloads |
|---|---|
| Introspection | ST_GeometryType, ST_IsEmpty, ST_NPoints, ST_X, ST_Y |
| Bounding box | ST_XMin, ST_XMax, ST_YMin, ST_YMax |
| Measurement | ST_Area, ST_Length, ST_Perimeter |
| Validation (DuckDB 2.0 build) | geosilo_is_valid, geosilo_validate, try_geosilo_decode |
The native overloads follow spatialβs semantics: ST_Area and ST_Perimeter count only polygonal parts (holes are subtracted from the area whichever way they are wound), ST_Length counts only linear parts (a polygon has length 0), ST_NPoints counts ring closures like WKB, and ST_X/ST_Y and the bounding-box accessors return NULL for empty geometries. On the DuckDB 2.0 build these semantics hold for MULTI* geometries and GEOMETRYCOLLECTIONs too; the Haybarn 1.5 build differs for ST_NPoints on multi-geometries, ST_Length on polygons, ST_Area on linestrings and empty geometries (NaN instead of NULL).
Everything else (ST_Buffer, ST_Union, ST_Intersection, ST_AsText, ST_Centroid, etc.) auto-decodes via the implicit cast and runs through the GEOS-backed spatial implementation.
Encoding format, briefly
The format is verifiable and small enough to summarize:
- Coordinates scale to integers (
-75.509491 Γ 1e7 = -755094910). - The first vertex of each ring is a 4-byte int32 absolute coordinate.
- Subsequent vertices are stored as 2-byte int16 deltas from the previous; ~90% fit. The rest use a 6-byte escape sequence.
- Polygon rings omit the closing duplicate vertex β itβs reconstructed on decode.
- Points use a 1-byte compact header.
The header (geometry_type, vertex_type, scale) is readable without decoding the body β see geosilo_metadata.
Untrusted blobs
On the DuckDB 2.0 build, decoding never trusts the bytes: every read is bounds-checked, element counts are checked against the remaining data before anything is allocated, and nesting is capped at 16 levels. A truncated, bit-flipped or otherwise malformed blob raises an Invalid Input Error rather than crashing DuckDB. To check blobs without raising errors:
SELECT geosilo_is_valid(b) AS ok, geosilo_validate(b) AS problem, try_geosilo_decode(b) AS geomFROM (VALUES (geosilo_encode(ST_Point(1, 2))), ('\x54\xff\xff\xff\x7f'::BLOB)) t(b);TRY_CAST(b AS GEOSILO) applies the same validation, including a check for trailing bytes.
Scale and precision
| CRS family | Units | Default scale | Precision |
|---|---|---|---|
EPSG:4326 / NAD83 |
degrees | 10,000,000 |
~1 cm |
UTM / EPSG:3857 |
meters | 100 |
1 cm |
Auto-applied when you declare GEOSILO('EPSG:...'). Override per-call with the two-argument form; the scale must be a positive integer and every scaled coordinate must fit in a 32-bit integer (about Β±214 at 1e7):
SELECT geosilo_encode(geom, 1000) FROM millimeter_data;Arrow IPC transport
GeoSilo registers an Arrow extension type named queryfarm.geosilo. A producer tags an Arrow binary field with the right metadata and the DuckDB consumer (with GeoSilo loaded) auto-decodes silo blobs to GEOMETRY on read and re-encodes on write β CRS rides through the fieldβs metadata:
geom_field = pa.field("geom", pa.binary(), metadata={ b"ARROW:extension:name": b"queryfarm.geosilo", b"ARROW:extension:metadata": b'{"crs":"EPSG:4326"}',})Sibling extensions in the geo bucket
a5β pentagonal global geospatial index for spatial aggregation, joins, and equal-area binning. Pairs well: index witha5, store the underlying geometry withgeosilo.lindelβ Hilbert / Morton space-filling curves for ordering multi-dimensional data on disk. Sort aGEOSILOtable by alindel-encoded centroid to keep nearby geometries on the same Parquet row group / DuckDB block.
Reference
Extension Contents
Quick reference to all available functions and settings organized by category.
| Name | Type | Description |
|---|---|---|
|
Encoding
Encode/decode between |
||
| geosilo_decode() | Object type: Scalar function |
Decode a GEOSILO blob back into a standard GEOMETRY.
|
| geosilo_encode() | Object type: Scalar function |
Encode a GEOMETRY into the compact GEOSILO format and return a BLOB.
|
| geosilo_metadata() | Object type: Scalar function | Read a GEOSILO blob's header without decoding the geometry. |
|
Introspection (native)
ST_* overloads with native GEOSILO implementations β type, emptiness, point count, X/Y, and the four bounding-box accessors. They read the silo header / delta stream directly without round-tripping through WKB, which is where the speed-up on bounding-box prefilters and per-row coordinate access comes from. |
||
| ST_GeometryType() | Object type: Scalar function | Native GEOSILO overload β returns the geometry type (e.g. |
| ST_IsEmpty() | Object type: Scalar function |
Native GEOSILO overload β TRUE if the encoded geometry has no vertices, including polygons, multi-geometries and collections made only of empty parts (GEOMETRYCOLLECTION(POINT EMPTY) is empty).
|
| ST_NPoints() | Object type: Scalar function | Native GEOSILO overload β total vertex count, walking the encoded geometry: every ring and sub-geometry is counted, polygon rings include their closing vertex (as in WKB), and empty points count as 0. |
| ST_X() | Object type: Scalar function |
Native GEOSILO overload β X coordinate of a POINT, read straight from the silo bytes without materializing a GEOMETRY.
|
| ST_XMax() | Object type: Scalar function | Native GEOSILO overload β maximum X across the geometry. |
| ST_XMin() | Object type: Scalar function | Native GEOSILO overload β minimum X across the geometry, computed by walking the integer delta stream. |
| ST_Y() | Object type: Scalar function |
Native GEOSILO overload β Y coordinate of a POINT, read straight from the silo bytes without materializing a GEOMETRY.
|
| ST_YMax() | Object type: Scalar function | Native GEOSILO overload β maximum Y across the geometry. |
| ST_YMin() | Object type: Scalar function | Native GEOSILO overload β minimum Y across the geometry. |
|
Measurement (native)
ST_* overloads for area, length, and perimeter computed directly on the integer delta stream (shoelace for area, accumulated in double precision). No WKB decode, no GEOS dependency surface for these calls. They follow spatial's semantics: area and perimeter count only polygonal parts, length only linear parts. |
||
| ST_Area() | Object type: Scalar function | Native GEOSILO overload β planar area of the polygonal parts, computed with the shoelace formula directly on the integer coordinates rebuilt from the delta stream (no WKB decode). |
| ST_Length() | Object type: Scalar function |
Native GEOSILO overload β total planar length of the linear parts (LINESTRING, MULTILINESTRING, and linestrings inside a GEOMETRYCOLLECTION), computed on the integer delta stream without rehydrating a GEOMETRY.
|
| ST_Perimeter() | Object type: Scalar function |
Native GEOSILO overload β perimeter of the polygonal parts, summed over every ring (holes included), computed on the integer delta stream without rehydrating a GEOMETRY.
|
|
Types
|
||
| GEOSILO | Object type: Logical type | Logical type registered by this extension. |
|
Validation
DuckDB 2.0 build only. Check GEOSILO blobs from untrusted sources without risking an error mid-query: |
||
| geosilo_is_valid() | Object type: Scalar function |
DuckDB 2.0 build only. Returns TRUE when the value is a structurally valid GEOSILO blob β a known header, element counts consistent with the data, nesting of at most 16 levels and no trailing bytes β and FALSE otherwise.
|
| geosilo_validate() | Object type: Scalar function |
DuckDB 2.0 build only. Validates a GEOSILO blob and returns NULL when it is valid, otherwise a message describing the first problem found β truncated data, a bad magic byte, an unsupported version, an element count larger than the data, excessive nesting or trailing bytes.
|
| try_geosilo_decode() | Object type: Scalar function |
DuckDB 2.0 build only. Decodes a GEOSILO blob into a GEOMETRY like geosilo_decode, but returns NULL instead of raising an error when the blob is malformed.
|
No extension contents match that search.
API Reference
Function Reference
Data model
Registered Types
Logical types this extension adds to DuckDB. Functions in the reference may accept or return these names directly.
-
GEOSILOLogical type registered by this extension.
Practical Examples
Cookbook
Real-world recipes and patterns for common use cases.
These examples use DuckDB 2.0 or later. Complete the repository setup and installation first.
Cookbook setup
Load both extensions. GeoSilo first also works with older builds that have the spatial-first registration bug:
INSTALL geosilo FROM query_farm; LOAD geosilo FROM query_farm;INSTALL spatial; LOAD spatial;Loading geosilo registers the GEOSILO column type and its native ST_* overloads. Loading spatial adds the wider geometry API used by these recipes. Builds containing the v1.5 registration fix support either load order; older build d088741 needs the order above.
Define a compact geometry table
The recommended shape β explicit CRS, ZSTD compression:
CREATE OR REPLACE TABLE parcels ( id INTEGER, name VARCHAR, geom GEOSILO('EPSG:4326') USING COMPRESSION zstd);The CRS lets GeoSilo pick a sensible integer scale automatically (1e7 for degrees, 100 for projected meters). USING COMPRESSION zstd is where the storage win comes from β without it, raw GEOSILO blobs are larger than DuckDBβs columnar GEOMETRY storage. See CREATE TABLE for the DDL surface.
Load from any GEOMETRY source
The implicit GEOMETRY β GEOSILO cast auto-encodes on insert:
-- From another DuckDB tableINSERT INTO parcelsSELECT id, name, geom FROM raw_parcels;-- From WKT in CSVINSERT INTO parcelsSELECT id, name, ST_GeomFromText(wkt) FROM read_csv('parcels.csv');-- From Parquet with a WKB columnINSERT INTO parcelsSELECT id, name, ST_GeomFromWKB(geom_wkb)FROM read_parquet('parcels.parquet');Sources can be any expression returning GEOMETRY β see spatialβs constructor functions for the full list.
Native bounding-box prefilter
The four ST_XMin / ST_XMax / ST_YMin / ST_YMax calls have GEOSILO-native implementations β they walk the integer delta stream without rebuilding a GEOMETRY. Use them in WHERE clauses to prefilter before any GEOS-backed work:
-- Everything in a longitude band β entirely nativeSELECT id, nameFROM parcelsWHERE ST_XMin(geom) > -78 AND ST_XMax(geom) < -76;-- Hand off to GEOS only for the survivors of the prefilterSELECT id, ST_AsText(ST_Centroid(geom))FROM parcelsWHERE ST_XMin(geom) > -78 AND ST_XMax(geom) < -76 AND ST_YMin(geom) > 39 AND ST_YMax(geom) < 41;See ST_XMin / ST_XMax / ST_YMin / ST_YMax.
Native area, length, perimeter
ST_Area on a GEOSILO column runs the shoelace formula on int64 coordinates rebuilt from the delta stream β no WKB decode:
-- Per-feature areaSELECT id, ST_Area(geom) AS areaFROM parcelsORDER BY area DESCLIMIT 10;-- Total length of a road networkSELECT SUM(ST_Length(geom)) AS total_road_lengthFROM roads;-- Perimeter histogramSELECT FLOOR(LOG(ST_Perimeter(geom))) AS bucket, COUNT(*) AS nFROM parcelsGROUP BY bucketORDER BY bucket;See ST_Area, ST_Length, ST_Perimeter.
Per-point coordinate access
ST_X / ST_Y on point geometries decode straight from the silo header:
SELECT id, ST_X(geom) AS lon, ST_Y(geom) AS latFROM stations;For non-point geometries, use ST_Centroid (which auto-decodes to GEOMETRY) and then ST_X / ST_Y on the resulting point.
Filter by geometry type without decoding
geosilo_metadata reads the silo header directly. Combine with ST_GeometryType (which is also native) to filter cheaply by type:
-- Counts by geometry type β no WKB decode per rowSELECT ST_GeometryType(geom) AS gtype, COUNT(*) AS nFROM mixed_geom_tableGROUP BY gtypeORDER BY n DESC;-- Inspect the integer scale of stored blobsSELECT geosilo_metadata(silo_blob) AS metaFROM compact_tableLIMIT 5;-- {'geometry_type':'POLYGON','vertex_type':'XY','scale':10000000}Manual encode / decode for BLOB pipelines
When you control the BLOB pipeline directly β exporting to a file format, shipping over a non-Arrow protocol, staging β use geosilo_encode and geosilo_decode:
-- Encode for exportCOPY ( SELECT id, geosilo_encode(geom) AS silo FROM parcels_geometry) TO 'parcels_silo.parquet' (FORMAT 'parquet');
-- Decode on readSELECT id, ST_AsText(geosilo_decode(silo)) AS wktFROM read_parquet('parcels_silo.parquet')LIMIT 5;To use a silo BLOB with the native ST_* overloads, cast it with ::GEOSILO. The cast is explicit only and validates the blob (on the DuckDB 2.0 build the whole structure, on the Haybarn 1.5 build the header): a bad blob raises a conversion error, or gives NULL with TRY_CAST. There is no cast from GEOSILO back to BLOB.
-- Native ST_* overloads on a silo BLOB, plus a header checkSELECT ST_XMin(silo::GEOSILO) AS xmin, ST_AsText(silo::GEOSILO) AS wkt, TRY_CAST('\x00\x01'::BLOB AS GEOSILO) AS bad_headerFROM (SELECT geosilo_encode(ST_GeomFromText('LINESTRING(0 0, 5 5)')) AS silo);-- 0.0 | LINESTRING (0 0, 5 5) | NULLFor a custom integer scale (e.g. millimeter-precision projected data), pass the second argument:
SELECT geosilo_encode(geom, 1000) FROM mm_precision_data;Validate blobs from untrusted sources
Silo BLOBs read from files or other systems may be truncated or corrupt. On the DuckDB 2.0 build, geosilo_is_valid filters them without raising errors, geosilo_validate says what is wrong, and try_geosilo_decode decodes or returns NULL:
SELECT id, geosilo_validate(silo) AS problem, ST_AsText(try_geosilo_decode(silo)) AS wktFROM (VALUES (1, geosilo_encode(ST_Point(1, 2))), (2, '\x54\xff\xff\xff\x7f'::BLOB)) t(id, silo);Keep only the valid rows before using the native ST_* overloads:
SELECT ST_XMin(silo::GEOSILO) AS xminFROM (VALUES (geosilo_encode(ST_Point(1, 2))), ('\x47\x01'::BLOB)) t(silo)WHERE geosilo_is_valid(silo);Mix native fast paths with GEOS-backed operations
Anything outside the native overload set auto-decodes through the implicit GEOSILO β GEOMETRY cast. You donβt need to think about it β but if youβre scanning many rows, push the native operations first to shrink the candidate set:
-- ST_Buffer auto-decodes; ST_XMin/XMax/YMin/YMax run native firstSELECT id, ST_AsText(ST_Buffer(geom, 0.001)) AS buffered_wktFROM parcelsWHERE ST_XMin(geom) > -78 AND ST_XMax(geom) < -76LIMIT 100;See the spatial extension for the GEOS-backed surface that auto-decodes.
Pair with sibling geo extensions
GeoSilo handles compact storage; pair it with the other geo bucket extensions for indexing and ordering:
-- a5: pentagonal geospatial index for aggregation / joinsINSTALL a5 FROM query_farm; LOAD a5 FROM query_farm;
-- Bin parcels by A5 cell at resolution 12SELECT a5_lonlat_to_cell(ST_X(ST_Centroid(geom)), ST_Y(ST_Centroid(geom)), 12) AS cell, COUNT(*) AS parcels_in_cellFROM parcelsGROUP BY cellORDER BY parcels_in_cell DESC;See a5 for the indexing surface, and lindel for space-filling curve ordering β sort a GEOSILO table by a Hilbert-encoded centroid to keep nearby geometries on the same DuckDB block / Parquet row group.
Platform Support
Compatibility
Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.
Quick Facts
Platforms
DuckDB 2.0.0
- Linux x86_64aarch64
- Linux (musl) Not available
- macOS Apple Silicon
- Windows x86_64x86_64 (MinGW)
- WASM Not available
Compiled binary sizes
| Platform | Architecture | Size |
|---|---|---|
| Linux | x86_64 | 4.69 MB |
| Linux | aarch64 | 3.96 MB |
| macOS | Apple Silicon | 3.32 MB |
| Windows | x86_64 | 10.23 MB |
| Windows | x86_64 (MinGW) | 17.85 MB |
Compressed download sizes for the release shown above.
DuckDB & Haybarn
Release calendar- DuckDB v2.0.0 Query.Farm repository Supported
- Haybarn v1.5.6 Built-in community repository Supported
Browser examples use Haybarn-Wasm 2.0.0-rc12.
Checked .
Learn and explore
Tutorials and articles
Writing about GeoSilo: how it works, what changed, and why.
-
GeoSilo for DuckDB 2.0: validate the bytes, preserve the geometry
GeoSilo adds full BLOB validation and safer decoding in DuckDB 2.0, repairs Z and M geometry round trips, and makes area, length and perimeter match Spatial.