Geocode addresses inside DuckDB offline — forward and reverse geocoding from one country file, no server, no API key
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.5.5 | 1.5.6 | 2.0.0 | 2.0.1 |
|---|---|---|---|---|
| Linux AMD64 | ||||
| Linux ARM64 | ||||
| macOS AMD64 | ||||
| macOS ARM64 | ||||
| Windows AMD64 | ||||
| Windows ARM64 | ||||
| WebAssembly |
Installing and Loading
INSTALL gridpin_ext FROM community;
LOAD gridpin_ext;
Example
-- Country data files are free downloads: https://gridpin.dev
-- (Australia, Belgium, Brazil, Canada, France, Germany, Italy, Mexico, the Netherlands, New Zealand, Poland, Serbia, Spain and the United States today; one file per country.)
LOAD gridpin_ext;
-- Point the extension at a downloaded sheet. One sheet is loaded at a time.
SELECT gridpin_load('./france.bin');
-- Forward geocoding: an address string in, a JSON object out.
SELECT gridpin_geocode('10 rue de rivoli paris');
-- Reverse geocoding: coordinates in, the nearest address out.
SELECT gridpin_reverse(48.8686, 2.3305);
-- It is an ordinary scalar function, so a whole table geocodes in one query.
SELECT id,
json_extract(gridpin_geocode(address), '$.lat') AS lat,
json_extract(gridpin_geocode(address), '$.lon') AS lon
FROM customers;
About gridpin_ext
GridPin geocodes addresses inside DuckDB entirely offline: gridpin_geocode(address) turns an address
string into coordinates, and gridpin_reverse(lat, lon) turns coordinates into the nearest street address. It
reads one memory-mapped file per country, answers in milliseconds on a single core and tolerates typos. There is
no server to run, no database to import, no API key and no per-request fee — the addresses you geocode never
leave the machine.
Functions
| Function | Purpose |
|---|---|
gridpin_load(path) |
memory-map a country sheet; the last path wins |
gridpin_geocode(address) |
address string → JSON object with lat, lon, street, city
|
gridpin_reverse(lat, lon) |
coordinates → JSON object for the nearest address |
gridpin_load_poi(path) |
optional points-of-interest layer, consulted after addresses |
gridpin_reset() |
drop the loaded sheet so another country can be loaded |
Every function carries a description and parameter names, so SQL assistants and
AI agents can discover them through duckdb_functions().
A query issued before gridpin_load is a clear error rather than a crash, and an
address with no match returns {} — an empty result is a documented contract, not a
guess.
Data files
Country sheets are free downloads at gridpin.dev and in the releases of the main repository: Australia, Belgium, Brazil, Canada, France, Germany, Italy, Mexico, the Netherlands, New Zealand, Poland, Serbia, Spain and the United States. The sheets are built from Overture Maps addresses and national open address registers; each carries its own source licence, listed in ATTRIBUTIONS.md. What each country covers and where it is thin is on its page under gridpin.dev/guides. The engine itself is Apache-2.0 and lives at gridpin/gridpin; this repository holds the extension crate only.
Licences
The extension statically links the Rust libraries listed in THIRDPARTY.yml, which carries their licence texts.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| gridpin_geocode | scalar | Return the best address or POI match as JSON, or an empty JSON object when nothing matches. | NULL | [SELECT gridpin_geocode('boulevard des moulins 27 monaco')] |
| gridpin_load | scalar | Load an address index for this database, requiring an explicit reset before changing its path. | NULL | [SELECT gridpin_load('mc.bin')] |
| gridpin_load_poi | scalar | Load an optional POI index that must match the address index country. | NULL | [SELECT gridpin_load_poi('mc_poi.bin')] |
| gridpin_reset | scalar | Unload the address and POI indexes in a standalone statement before switching sheets. | NULL | [SELECT gridpin_reset()] |
| gridpin_reverse | scalar | Return the nearest indexed house as JSON for finite coordinates, or an empty JSON object when none is nearby. | NULL | [SELECT gridpin_reverse(43.7391, 7.4266)] |
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 |