Skip to main content
WherobotsDB stores tables in Apache Iceberg. New tables in Wherobots-managed catalogs, such as org_catalog, are format-version 3 (V3), which has geometry and geography column types, and Wherobots adds a raster column type. Tables created before September 15, 2026 were created at format-version 2 (V2), and Wherobots doesn’t raise them to V3. Which column types a table can have, and whether WherobotsDB skips data files for spatial filters, depend on its format version; see the Iceberg Tables Overview. A raster column holds in-db or out-db rasters, and the RS_ functions in WherobotsDB work on them. This page shows how to create, write, and query tables with raster columns. The examples use the catalog name org_catalog; replace it with the name of the catalog you write to.

Creating a table with a raster column

Choose the format version before you create the table. WherobotsDB skips data files for raster spatial filters only on format-version 1 and 2 tables, and a new table in a Wherobots-managed catalog is format-version 3. A table can’t be lowered from format-version 3 to 2. The two examples below create format-version 2 tables, with TBLPROPERTIES ('format-version'='2') on CREATE TABLE and .tableProperty("format-version", "2") before .create(). Leave the property off if you don’t filter the rasters spatially, or if the table needs a GEOMETRY(<srid>) or GEOGRAPHY(<srid>) column, which requires format-version 3. See Raster columns on the push-down page. Declare the column with the raster type:
This creates an empty table with a raster column rast. Inspect the table schema with DESCRIBE TABLE:
Or with printSchema():
SHOW CREATE TABLE prints a raster column as rast BINARY on a format-version 3 table. The column still holds rasters, stored the same way as on a format-version 2 table. To create a table from a DataFrame that holds rasters, call writeTo(...).create():

Writing data

Storing raster data in a table is similar to PostGIS. There are two options for storing raster data:
  • in-db raster: raster data completely stored in a table.
  • out-db raster: raster data is stored in an external file (such as GeoTIFF file on S3) and the table stores the path to the file and geo-referencing metadata of that raster.

In-DB Raster

To construct in-db raster data and write them to a table, user can use RS_FromGeoTiff to construct a raster value and write the DataFrame using .writeTo(...).append()
Or load the GeoTIFF files with the raster data source, which reads them as out-db rasters, then use RS_AsInDB to convert them to in-db rasters. Take the path with RS_BandPath before the conversion, because an in-db raster no longer references its source file:

Out-DB Raster

To write out-db rasters to a table, load the raster files with the raster data source and write the DataFrame. Each row holds an out-db raster that references the file. The name column holds only the file name, so these examples write the full path from RS_BandPath to data. The EuroSAT sample files aren’t internally tiled, so these examples set retile to false and load each file as one raster. For tiled files such as Cloud Optimized GeoTIFFs, leave tiling on to write one row for each tile:

Updating, deleting, and merging data

UPDATE, DELETE, and MERGE INTO work on raster tables, in both copy-on-write and merge-on-read mode. The syntax is the same as in Apache Iceberg; see Apache Iceberg - Write with SQL.

Querying data

Load a table into a DataFrame with sedona.table(...):
You can set read options when you load the table. For example, with a smaller split size, the table is read into more partitions:
Run a spatial range query with Spatial SQL:
Or with the DataFrame API:
You can also load a table by naming the data source with .format("iceberg"). This loads an isolated table reference, which doesn’t refresh automatically when the table changes:
On format-version 1 and 2 tables, WherobotsDB skips the data files whose rasters can’t match a raster spatial filter. See Raster columns on the push-down page.

Working with raster data

A raster column is read as RasterUDT values, which every RS_ function in WherobotsDB works on. For example, RS_MapAlgebra creates a new raster by applying a map algebra expression to each raster:
To write the result to a new table, use CREATE TABLE ... AS SELECT:
Or call writeTo(...).create() on the DataFrame the query returns:
Both create a format-version 3 table in a Wherobots-managed catalog. To filter the result spatially with file skipping, set the format version as described in Creating a table with a raster column.

Iceberg Tables Overview

Format versions, spatial file skipping, and format-version 3 features.

Spatial Filter Push-down and Clustering

Partition or cluster a raster table so WherobotsDB skips more data files for raster filters.

Tune Out-DB Raster Reads

When to use in-db or out-db rasters, and how to tune the out-db raster cache.

Apache Iceberg documentation for Spark

Table maintenance, procedures, and the rest of the Iceberg Spark integration.