Lightweight Geohash utilities for DuckDB, including coordinate and geometry encoding, cell decoding, bounding boxes, and neighbors.
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 |
|---|---|---|---|---|---|
| Linux AMD64 | |||||
| Linux ARM64 | |||||
| macOS AMD64 | |||||
| macOS ARM64 | |||||
| Windows AMD64 | |||||
| Windows ARM64 | |||||
| WebAssembly |
Installing and Loading
INSTALL pintail FROM community;
LOAD pintail;
Example
INSTALL pintail FROM community;
LOAD pintail;
-- Recommended: GEOMETRY coordinates use longitude, latitude.
SELECT st_geohash('POINT(121.4737 31.2304)'::GEOMETRY, 6);
-- wtw3sj
About pintail
Pintail provides dependency-free Geohash utilities for DuckDB. New support references PostGIS documentation and behavior, with Pintail-specific API choices. Encode points, lines, polygons, multi-geometries, and collections using a Geohash cell that covers the entire geometry. GEOMETRY input is recommended for new queries and uses longitude, latitude; existing numeric calls retain latitude, longitude order.
Decode Geohashes to cell-center POINTs, cell-boundary POLYGONs, or bounding-box STRUCTs, and find the eight neighboring cells. st_box2dfromgeohash is an alias of st_geohash_bbox and returns the same STRUCT. Function signatures, descriptions, examples, and catalog comments are available through duckdb_functions().
Geometry functions use DuckDB Core GEOMETRY without requiring Spatial, GEOS, PROJ, or PostGIS. Decoded geometries carry EPSG:4326 coordinates.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| pintail | scalar | Internal load-path smoke function; returns a Pintail diagnostic string. | Returns a Pintail diagnostic string used to verify that the extension loaded. | [pintail('load-smoke')] |
| st_box2dfromgeohash | scalar | Decode a Geohash prefix to a BOX2D-compatible latitude/longitude bounding box. | Alias of st_geohash_bbox. Returns the same latitude/longitude STRUCT; DuckDB has no PostgreSQL BOX2D type. | [st_box2dfromgeohash('ezs42-extra', 5)] |
| st_box2dfromgeohash | scalar | Decode a Geohash to a BOX2D-compatible latitude/longitude bounding box. | Alias of st_geohash_bbox. Returns the same latitude/longitude STRUCT; DuckDB has no PostgreSQL BOX2D type. | [st_box2dfromgeohash('ezs42')] |
| st_geohash | scalar | Encode a geometry extent as a Geohash with an optional maximum character count. | Encodes a Geohash. Numeric arguments are latitude then longitude; geometry XY is longitude then latitude, and the hash covers the entire extent in at most 20 characters. | [st_geohash('POINT(121.4737 31.2304)'::GEOMETRY, 6)] |
| st_geohash | scalar | Encode latitude and longitude as a standard Geohash Base32 string. | Encodes a Geohash. Numeric arguments are latitude then longitude; geometry XY is longitude then latitude, and the hash covers the entire extent in at most 20 characters. | [st_geohash(31.2304, 121.4737, 6)] |
| st_geohash | scalar | Encode latitude and longitude using the default Geohash precision. | Encodes a Geohash. Numeric arguments are latitude then longitude; geometry XY is longitude then latitude, and the hash covers the entire extent in at most 20 characters. | [st_geohash(31.2304, 121.4737)] |
| st_geohash | scalar | Encode the smallest Geohash cell containing a geometry's complete XY extent. | Encodes a Geohash. Numeric arguments are latitude then longitude; geometry XY is longitude then latitude, and the hash covers the entire extent in at most 20 characters. | [st_geohash('LINESTRING(-126 48, -126.1 48.1)'::GEOMETRY)] |
| st_geohash_bbox | scalar | Decode a Geohash prefix to its latitude/longitude bounding box. | Decodes a Geohash to a STRUCT bounding box (min_lat, min_lon, max_lat, max_lon). Omitted or negative precision uses the full hash; zero decodes the world cell. | [st_geohash_bbox('ezs42-extra', 5)] |
| st_geohash_bbox | scalar | Decode a Geohash to its latitude/longitude bounding box. | Decodes a Geohash to a STRUCT bounding box (min_lat, min_lon, max_lat, max_lon). Omitted or negative precision uses the full hash; zero decodes the world cell. | [st_geohash_bbox('ezs42')] |
| st_geohash_neighbors | scalar | Return the eight adjacent Geohash cells in [N, NE, E, SE, S, SW, W, NW] order. | Returns the eight adjacent Geohash cells in [N, NE, E, SE, S, SW, W, NW] order, wrapping at the antimeridian and across the poles. | [st_geohash_neighbors('ezs42')] |
| st_geomfromgeohash | scalar | Decode a Geohash prefix to the polygon boundary of its cell. | Returns a Geohash cell boundary as an EPSG:4326 POLYGON (x=longitude, y=latitude). | [st_geomfromgeohash('c0w3h-extra', 5)] |
| st_geomfromgeohash | scalar | Decode a Geohash to the polygon boundary of its cell. | Returns a Geohash cell boundary as an EPSG:4326 POLYGON (x=longitude, y=latitude). | [st_geomfromgeohash('c0w3h')] |
| st_pointfromgeohash | scalar | Decode a Geohash prefix to the center point of the selected cell. | Returns the center of a Geohash cell as an EPSG:4326 POINT (x=longitude, y=latitude). | [st_pointfromgeohash('wtw3sj-extra', 6)] |
| st_pointfromgeohash | scalar | Decode a Geohash to the center point of its cell. | Returns the center of a Geohash cell as an EPSG:4326 POINT (x=longitude, y=latitude). | [st_pointfromgeohash('wtw3sj')] |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |