⌘+k ctrl+k
1.4 (stable)
Search Shortcut cmd + k | ctrl + k
Spatial Extension

The spatial extension provides support for geospatial data processing in DuckDB. For an overview of the extension, see our blog post.

Installing and Loading

To install the spatial extension, run:

INSTALL spatial;

Note that the spatial extension is not autoloadable. Therefore, you need to load it before using it:

LOAD spatial;

The GEOMETRY Type

The core of the spatial extension is the GEOMETRY type, which is a flexible and extensible data type for representing geometric objects. The GEOMETRY type used to be provided by the spatial extension, but it became a built-in data type in DuckDB v1.5. However, almost all of the associated functions for working with geometries (e.g., calculating distances, areas, intersections) are still part of spatial.

Besides operating on GEOMETRY, the spatial extension also includes a couple of experimental non-standard explicit geometry types, such as POINT_2D, LINESTRING_2D, POLYGON_2D and BOX_2D that are based on DuckDBs native nested types, such as STRUCT and LIST. Since these have a fixed and predictable internal memory layout, it is theoretically possible to optimize a lot of geospatial algorithms to be much faster when operating on these types than on the GEOMETRY type. However, only a couple of functions in the spatial extension have been explicitly specialized for these types so far. All of these new types are implicitly castable to GEOMETRY, but with a small conversion cost, so the GEOMETRY type is still the recommended type to use if you are planning to work with a lot of different spatial functions.

Pages in This Section

© 2026 DuckDB Foundation, Amsterdam NL
Code of Conduct Trademark Use