Skip to main content
SedonaDB is a single-node spatial database engine from the Apache Sedona project. It runs inside your Python process, on a laptop or a server. The wherobots-catalog package connects SedonaDB to Wherobots-managed catalogs, so you can query their tables without starting a Wherobots runtime. Queries run on your machine, and SedonaDB reads table files from cloud storage over the network. Wherobots issues the storage credentials for each table, so you don’t configure storage keys. The integration supports:
  • Reading Iceberg v2 and v3 tables, including tables with deleted rows.
  • Reading geometry columns, with or without a declared coordinate reference system (CRS). See Work with geometry.
The integration doesn’t support:
  • Writing tables. INSERT, CREATE TABLE, DELETE, and DROP TABLE fail with a “not implemented” error. Write tables from WherobotsDB instead.
  • Tables with raster columns. Any query on these tables fails with Havasu raster columns (rast) cannot be read yet, even if it doesn’t select the raster column. Query them in WherobotsDB instead.
  • Foreign catalogs. list_catalogs() includes catalogs such as AWS Glue and Databricks Unity Catalog, but reading them fails with namespace operations are only valid for MANAGED catalogs. To query them, connect WherobotsDB to external catalogs.
For the scope of this workflow and compatibility considerations, see Connect external engines to Wherobots catalogs.

Before you start

Ensure that you have the following:
  • Python 3.10 or later.
  • A Wherobots API key, created for your user or for a service principal.
  • Access to the Wherobots-managed catalog you want to read. The samples on this page use the wherobots_open_data catalog.

Connect SedonaDB to a Wherobots catalog

1

Install the packages

2

Set your API key

To pass the key from your own code instead, call wherobots.catalog.login(api_key=...).
3

Connect to your catalogs

login() returns the catalogs that your API key can access. sd.register(wbc) makes them available to SQL in your sd session.
4

Verify the connection

The output lists the tables in the overture_maps_foundation namespace, also known as a database:
In a Job Run, SedonaDB is preinstalled, so install only wherobots-catalog. login() finds the Job Run’s credentials, so you don’t need an API key.

Browse catalogs

Use attributes or indexing to move from a catalog to a namespace to a table. Use indexing for names that aren’t valid Python identifiers.
Both places assignments return the same table.

Query a table

Query a table with SQL or with the DataFrame API. Both samples find the libraries in a bounding box around Boston. Neither reads data until you call a method such as show().
Both samples print the following:

Save query results

to_pandas() loads the result into memory on your machine and returns a GeoPandas GeoDataFrame when the result has a geometry column. to_parquet() writes the result to a local file.

Join a table with local data

SedonaDB uses a spatial filter on a catalog table to skip files that can’t match it. A join condition doesn’t skip files, so a join on its own reads the whole table. Filter the catalog table first, then join the result. This sample registers a local GeoDataFrame as a view and counts the places in each area:
To check how much of a table a query reads, run it with EXPLAIN and find WherobotsTableExec in the plan. In the run behind this sample, the plan shows groups=2 with the filter and groups=206 for the join on its own.

Work with geometry

The CRS that SedonaDB uses for a geometry column depends on what the column declares. Run SHOW CREATE TABLE in WherobotsDB to see the declaration: To see the CRS that SedonaDB uses, print the column from the table’s schema:

Troubleshooting

WHEROBOTS_API_KEY isn’t set in the environment that runs Python. Set it, or pass the key with wherobots.catalog.login(api_key=...).If the error is Authentication failed (HTTP 401) instead, the key isn’t valid. Create a new API key.
The geometry in your query has no CRS, or a different CRS from the column. Pass an SRID to the function that creates the geometry, such as ST_MakeEnvelope(-71.19, 42.22, -70.92, 42.40, 4326). If the two CRSs differ, convert one with ST_Transform.
to_view() isn’t available on a table object. Create the view from SQL in your own session instead:

Next steps

Wherobots open data

Find the datasets in the wherobots_open_data catalog.

Geometry tables

Create tables with geometry columns that declare a CRS.

SedonaDB documentation

Learn the SedonaDB SQL functions and DataFrame API.