Sedona Configuration#

The sedona_configuration module provides functions for configuring and initializing Apache Sedona.

libadalina_core.sedona_configuration.get_sedona_context() SparkSession[source]#

Get the Sedona context for spatial data processing. This context is the one used for all spatial operations in libadalina.

If the Sedona context has not been initialized yet with init_sedona_context, the function init_sedona_context will be called to initialize it with the default configuration.

Returns:

The Sedona context as a SparkSession.

Return type:

pyspark.sql.SparkSession

libadalina_core.sedona_configuration.init_sedona_context(spark_master: str | None = None, spark: SparkSession | None = None, spark_configs: dict[str, str] | None = None)[source]#

Initialize the Sedona context for spatial data processing.

This function can either:

  1. Create a new Sedona context with a specified Spark master,

  2. Use an existing SparkSession, or

  3. Create a default Sedona context with the default Spark configuration.

If no parameters are provided, it will create a default Sedona context (option 3).

If a JAVA_HOME environment variable is not set, it will attempt to install a compatible JDK.

Parameters:
  • spark_master (str, optional) – The Spark master URL to connect to. If provided, a new Sedona context will be created with this master.

  • spark (pyspark.sql.SparkSession, optional) – An existing SparkSession to use. If provided, it will be used to create the Sedona context.

Examples

Initialize the global Sedona session with a default configuration

>>> init_sedona_context()

Initialize the global Sedona session referencing to a given Spark master

>>> init_sedona_context(spark_master="spark://localhost:7077")

Initialize the session using a pre-existing SparkSession

>>> spark = SparkSession.builder.getOrCreate()
>>> init_sedona_context(spark=spark)