Introduction¶
Function list¶
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")
Alternatively, expr and selectExpr can be used:
myDataFrame.withColumn("geometry", expr("ST_*")).selectExpr("ST_*")
- Constructor: Construct a Geometry given an input string or coordinates
- Example: ST_GeomFromWKT (string). Create a Geometry from a WKT String.
- Documentation: Here
- Function: Execute a function on the given column or columns
- Example: ST_Distance (A, B). Given two Geometry A and B, return the Euclidean distance of A and B.
- Documentation: Functions are organized by category. See Geometry Accessors, Geometry Editors, Measurement Functions, Geometry Processing, Overlay Functions, and other categories in the sidebar.
- Aggregate function: Return the aggregated value on the given column
- Example: ST_Envelope_Aggr (Geometry column). Given a Geometry column, calculate the entire envelope boundary of this column.
- Documentation: Here
- Predicate: Execute a logic judgement on the given columns and return true or false
- Example: ST_Contains (A, B). Check if A fully contains B. Return "True" if yes, else return "False".
- Documentation: Here
Sedona also provides an Adapter to convert SpatialRDD <-> DataFrame. Please read Adapter Scaladoc
SedonaSQL supports SparkSQL query optimizer, documentation is Here
Raster function list¶
SedonaSQL also supports raster data processing. Raster functions use the RS_ prefix. All raster operators can be called in the same way as vector operators:
var myDataFrame = sedona.sql("YOUR_SQL")
- Constructor: Construct a Raster given an input file or parameters
- Example: RS_FromGeoTiff (binary). Create a Raster from a GeoTiff binary.
- Documentation: Here
- Function: Execute a function on the given Raster column or columns
- Example: RS_Value (raster, point). Given a Raster and a Point geometry, return the pixel value at that location.
- Documentation: Functions are organized by category. See Raster Accessors, Raster Operators, Raster Band Accessors, Raster Output, and other categories in the sidebar.
- Aggregate function: Return the aggregated value on the given Raster column
- Example: RS_Union_Aggr (Raster column). Given a Raster column, combine all rasters into a single multiband raster.
- Documentation: Here
- Predicate: Execute a logic judgement on the given columns and return true or false
- Example: RS_Intersects (raster, geometry). Check if a raster intersects a geometry. Return "True" if yes, else return "False".
- Documentation: Here
Raster quick start¶
The detailed explanation is here Write a Raster DataFrame/SQL application.
Quick start¶
The detailed explanation is here Write a SQL/DataFrame application.
- Add Sedona-core and Sedona-SQL into your project pom.xml or build.sbt
- Create your Sedona config if you want to customize your SparkSession.
import org.apache.sedona.spark.SedonaContext
val config = SedonaContext.builder().
master("local[*]").appName("SedonaSQL")
.getOrCreate()
- Add the following line after your Sedona context declaration:
import org.apache.sedona.spark.SedonaContext
val sedona = SedonaContext.create(config)