Skip to main content
WherobotsDB is the spatial query engine in Wherobots Notebook Runtimes and Job Runs. It keeps the Apache Sedona API names, so code identifiers such as SedonaContext, the sedona session variable, and sedona.* configuration keys refer to WherobotsDB.

Create a session

Start each notebook or job script by creating a session:
sedona is a Spark session with the WherobotsDB functions registered. In Wherobots, it reads and writes your Organization’s catalogs, such as org_catalog, with no further configuration. Call the ST_ vector functions and the RS_ raster functions in SQL with sedona.sql, or in DataFrame code with selectExpr and expr. For the functions, see Vector SQL APIs and Raster SQL APIs.

Create, load, and query a table

In the following steps, you create a table in org_catalog, your Organization’s default managed catalog, load NYC taxi trips from a CSV file into it, and query the trips by location. To write to another catalog, replace org_catalog.

Create a table

Create a database and a table with a GEOMETRY(4326) column for the pickup locations. 4326 declares the column’s CRS as WGS 84 longitude and latitude; see Geometry and Geography Tables.

Load a CSV file

Read the sample CSV file of NYC taxi trips from S3, and build the columns of the table from it:
The CSV reader returns every column as a string, so the coordinates and fares are cast to DOUBLE. ST_Point returns points with SRID 0, and WherobotsDB rejects SRID 0 points written to a GEOMETRY(4326) column, so ST_SetSRID labels them with SRID 4326 without changing their coordinates. See Matching the column CRS. Some payment types appear in the file in two cases, such as CASH and Cash, so UPPER merges them.

Write to the table

Append the DataFrame to the table. Running append again adds the rows a second time, so run it once:

Query the table

Count the trips that started in a box around Manhattan, and average their fares by payment type:
93,130 of the 99,998 trips in the file started inside the box:
To remove the example table, run sedona.sql("DROP TABLE org_catalog.test_db.taxi_trips").

Next steps

Load Vector Data

Read GeoParquet, shapefiles, GeoJSON, and other vector formats into DataFrames.

Load Raster Data

Load GeoTIFF files and STAC assets as rasters, and tune out-DB raster reads.

Geometry and Geography Tables

Declare a column’s CRS, write and query geometry data, and use geography columns.

Your Organization's Catalogs

Use org_catalog, or create a managed catalog backed by your own S3 storage.