Skip to contents

Setup and Connection

Install the spatial extension and manage DuckDB connections

ddbs_create_conn()
Create a DuckDB connection with spatial extension
ddbs_stop_conn()
Close a DuckDB connection
ddbs_install()
Checks and installs the Spatial extension
ddbs_load()
Loads the Spatial extension
ddbs_options()
Get or set global duckspatial options
ddbs_set_resources() ddbs_get_resources()
Get or set connection resources
ddbs_sitrep()
Report duckspatial configuration status

Data Import / Export

Read and write spatial data to and from DuckDB

ddbs_open_dataset()
Open spatial dataset lazily via DuckDB
ddbs_read_table()
Reads a vectorial table from DuckDB into R
ddbs_write_dataset()
Write spatial dataset to disk
ddbs_write_table()
Write an SF Object to a DuckDB Database
ddbs_register_table()
Register an SF Object as an Arrow Table in DuckDB

Spatial Predicates

Test spatial relationships between geometries

Spatial Joins and Filters

Combine or subset geometries based on spatial relationships

ddbs_intersection() ddbs_difference() ddbs_sym_difference()
Geometry binary operations
ddbs_filter()
Perform a spatial filter
ddbs_interpolate_aw()
Areal-Weighted Interpolation using DuckDB
ddbs_join()
Perform a spatial join of two geometries

Geometry Construction

Create new geometries from scratch or from existing data

ddbs_as_spatial()
Generate point geometries from coordinates
ddbs_generate_points()
Generate random points within bounding boxes of geometries
ddbs_quadkey()
Convert point geometries to QuadKey tiles

Geometry Processing

Modify, simplify, and transform individual geometries

ddbs_boundary()
Get the boundary of geometries
ddbs_buffer()
Creates a buffer around geometries
ddbs_build_area()
Build polygon areas from multiple linestrings
ddbs_centroid()
Calculates the centroid of geometries
ddbs_concave_hull()
Compute the concave hull of geometries
ddbs_convex_hull()
Compute the convex hull of geometries
ddbs_endpoint()
Extracts the endpoint of a linestring geometry
ddbs_exterior_ring()
Extract the exterior ring of polygons
ddbs_make_polygon()
Create a polygon from a single closed linestring
ddbs_polygonize()
Assemble polygons from multiple linestrings
ddbs_union() ddbs_combine() ddbs_union_agg()
Union and combine geometries
ddbs_voronoi()
Computes a Voronoi diagram from point geometries

Coordinate Operations

Transform and manipulate coordinate systems

ddbs_transform()
Transform the coordinate reference system of geometries
ddbs_flip_coordinates()
Flips the X and Y coordinates of geometries

Geometry Validation

Check and repair geometry validity and dimensionality

ddbs_geometry_type()
Get the geometry type of features
ddbs_make_valid()
Make invalid geometries valid
ddbs_simplify()
Simplify geometries
ddbs_is_simple() ddbs_is_valid() ddbs_is_closed() ddbs_is_empty() ddbs_is_ring()
Geometry validation functions
ddbs_has_z() ddbs_has_m()
Check geometry dimensions
ddbs_force_2d() ddbs_force_3d() ddbs_force_4d()
Force geometry dimensions

Format Conversion

Convert geometries to and from standard spatial formats

ddbs_as_text() ddbs_as_wkb() ddbs_as_hexwkb() ddbs_as_geojson()
Convert geometries to standard interchange formats

Spatial Extent and Boundaries

Extract bounding boxes and envelopes

ddbs_bbox()
Get the bounding box of geometries
ddbs_envelope()
Get the envelope (bounding box) of geometries

Affine Transformations

Rotate, scale, shear, and shift geometries

ddbs_flip()
Flip geometries horizontally or vertically
ddbs_rotate()
Rotate geometries around their centroid
ddbs_rotate_3d()
Rotate 3D geometries around an axis
ddbs_scale()
Scale geometries by X and Y factors
ddbs_shear()
Shear geometries
ddbs_shift()
Shift geometries by X and Y offsets

Measurements

Calculate areas, distances, lengths, and perimeters

ddbs_area() ddbs_length() ddbs_perimeter() ddbs_distance()
Calculate geometric measurements

Database Utilities

Helper functions for managing DuckDB schemas and metadata

ddbs_create_schema()
Check and create schema
ddbs_crs()
Check CRS of spatial objects or database tables
ddbs_drivers()
Get list of GDAL drivers and file formats
ddbs_glimpse()
Check first rows of the data
ddbs_list_tables()
Check tables and schemas inside a database

Lazy Spatial Data Frames

Create and work with lazy duckspatial_df objects