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_extension_info()
Glimpse the status of a DuckDB 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
ddbs_read_meta()
Read metadata from a spatial file

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() ddbs_crop() ddbs_shortest_line()
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_points()
Generate point geometries from coordinates
ddbs_point()
Create point geometries from coordinate vectors
ddbs_generate_points()
Generate random points within bounding boxes of geometries
ddbs_quadkey()
Convert point geometries to QuadKey tiles

Geometry Processing - General

Modify, simplify, and transform individual geometries

ddbs_buffer()
Creates a buffer around geometries
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_exterior_ring()
Extract the exterior ring of polygons
ddbs_maximum_inscribed_circle()
Computes the maximum inscribed circle of a geometry
ddbs_make_line()
Create lines from point geometries
ddbs_normalize()
Normalize geometries to a canonical form
ddbs_reverse()
Reverse the vertex order of geometries
ddbs_vertices()
Collect all vertices of a geometry into a MULTIPOINT
ddbs_voronoi()
Computes a Voronoi diagram from point geometries

Geometry Processing - Linestrings

Specialized functions for working with linestring geometries

ddbs_line_startpoint() ddbs_line_endpoint()
Extract the start or end point of a linestring geometry
ddbs_line_interpolate()
Interpolates a point or points along a line geometry
ddbs_line_locate_point()
Locate a point along a linestring
ddbs_line_merge()
Merge line geometries into a single line
ddbs_line_node()
Node a set of linestrings
ddbs_line_substring()
Extract a substring of a line geometry
ddbs_build_area()
Build polygon areas from multiple linestrings
ddbs_make_polygon()
Create a polygon from a single closed linestring
ddbs_polygonize()
Assemble polygons from multiple linestrings

Geometry Type Conversion

Change geometry types or decompose multi-part geometries

ddbs_dump()
Dumps geometries into their component parts
ddbs_multi()
Convert geometries to multi-type
ddbs_union() ddbs_combine() ddbs_union_agg()
Union and combine geometries
ddbs_intersection_agg()
Aggregate the intersection of geometries

Coordinate Operations

Transform and manipulate coordinate systems

ddbs_transform()
Transform the coordinate reference system of geometries
ddbs_set_crs()
Set the coordinate reference system of geometries
ddbs_flip_coordinates()
Flips the X and Y coordinates of geometries
ddbs_x() ddbs_y() ddbs_m() ddbs_z()
Extract coordinates from geometries
ddbs_xmax() ddbs_xmin() ddbs_ymax() ddbs_ymin() ddbs_zmax() ddbs_zmin() ddbs_mmax() ddbs_mmin()
Coordinate bounds of geometries
ddbs_force_2d() ddbs_force_3d() ddbs_force_4d()
Force geometry dimensions

Dimension operations

Utility functions for M and Z dimensions

ddbs_locate_along() ddbs_locate_between()
Locate geometries at specific M values
ddbs_has_z() ddbs_has_m()
Check geometry dimensions

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_reduce_precision()
Reduce the coordinate precision of geometries
ddbs_remove_repeated_points()
Remove repeated points from a geometry
ddbs_simplify()
Simplify geometries
ddbs_is_simple() ddbs_is_valid() ddbs_is_closed() ddbs_is_empty() ddbs_is_ring()
Geometry validation functions

Format Conversion

Convert geometries to and from standard spatial formats

Vector Tiles (MVT)

Encode geometries as Mapbox Vector Tiles for web mapping

ddbs_as_mvt_geom()
Transform geometries into Mapbox Vector Tile coordinate space
ddbs_write_mbtiles()
Write a Mapbox Vector Tile pyramid to an MBTiles file

Spatial Extent and Boundaries

Extract bounding boxes and envelopes

ddbs_bbox()
Get the bounding box of geometries
ddbs_boundary()
Get the boundary of geometries
ddbs_envelope()
Get the envelope (bounding box) of geometries
ddbs_make_envelope()
Create a rectangular polygon from bounding coordinates
ddbs_minimum_rotated_rectangle()
Computes the minimum rotated rectangle enclosing a geometry

Affine Transformations

Rotate, scale, shear, and shift geometries

ddbs_affine()
Apply an affine transformation to 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

Geometry Queries

Query structural properties of geometries without modifying them

ddbs_get_npoints() ddbs_get_ngeometries() ddbs_get_ninterior_rings()
Count geometry components
ddbs_dimension()
Get the topological dimension of a geometry

Measurements

Calculate areas, distances, lengths, perimeters, and bearings

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