Skip to content

Set up SedonaContext

Tip

We provide many ready-to-use example Python Jupyter notebooks. Please try them out: Wherobots examples.

SedonaSQL supports SQL/MM Part3 Spatial SQL Standard. It includes four kinds of SQL operators as follows. All these operators can be directly called through:

var myDataFrame = sedona.sql("YOUR_SQL")
myDataFrame.createOrReplaceTempView("spatialDf")
Dataset<Row> myDataFrame = sedona.sql("YOUR_SQL")
myDataFrame.createOrReplaceTempView("spatialDf")
myDataFrame = sedona.sql("YOUR_SQL")
myDataFrame.createOrReplaceTempView("spatialDf")

Alternatively, expr and selectExpr can be used:

myDataFrame.withColumn("geometry", expr("ST_*")).selectExpr("ST_*")

Detailed SedonaSQL APIs are available here: SedonaSQL API. You can find example county data (i.e., county_small.tsv) in Sedona GitHub repo.

Pure SQL environment

You can directly Sedona in a SQL environment such as Databricks SQL notebooks.

Scala, Java, Python environment

If you use Sedona with Scala, Java, or Python, add the following line at the beginning of your code:

import org.apache.sedona.spark.SedonaContext

val sedona = SedonaContext.create(spark)
import org.apache.sedona.spark.SedonaContext;

SparkSession sedona = SedonaContext.create(spark)
from sedona.spark import *

sedona = SedonaContext.create(spark)

This function will create a SedonContext with necessary settings


Last update: August 30, 2023 18:56:20