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:- Python
- Scala
- Java
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 inorg_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 aGEOMETRY(4326) column for the pickup locations. 4326 declares the column’s CRS as WGS 84 longitude and latitude; see Geometry and Geography Tables.
- Python
- Scala
- Java
Load a CSV file
Read the sample CSV file of NYC taxi trips from S3, and build the columns of the table from it:- Python
- Scala
- Java
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. Runningappend again adds the rows a second time, so run it once:
- Python
- Scala
- Java
Query the table
Count the trips that started in a box around Manhattan, and average their fares by payment type:- Python
- Scala
- Java
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.
