Working with geospatial data
Geospatial data describes the location and attributes of spatial objects. The DuckDB spatial extension adds support for working with geospatial data types. With the spatial extension loaded, we can store, query, analyze, and manipulate geospatial data in DuckDB using SQL commands.
The primary data type that the spatial extension introduces is the GEOMETRY data type. Underlying each GEOMETRY object is a more specific geometric subtype, such as POINT and LINE, which we will see shortly as part of researching a trip to the wine regions of France. We’ll be using geospatial data to calculate the distances between locations, and we’ll also be applying spatial filters to find candidate wine destinations to visit.
The spatial extension
Our first step is to install and load the DuckDB spatial extension:
INSTALL spatial; LOAD spatial;
With the extension installed and loaded, let’s start our exploration of Paris. Imagine we are next...