Skip to content
πŸŽ‰ Apache Sedona 1.9.1 is out now! πŸ—ΊοΈ Geography SQL functions, Box2D & Box3D types, raster Python UDFs & more. Read the release notes β†’

Install Sedona Python

The base apache-sedona package installs shapely and attrs. Using Sedona with Spark also requires PySpark, which is often preinstalled on managed Spark platforms.

Use pip to install the published package and any extras you need. Sedona uses uv to manage dependencies when developing the project. Package dependencies and version constraints are defined in python/pyproject.toml.

Install sedona

pip install apache-sedona
  • Since Sedona v1.1.0, pyspark is an optional dependency of Sedona Python because spark comes pre-installed on many spark platforms. To install pyspark along with Sedona Python in one go, use the spark extra:
pip install "apache-sedona[spark]"
  • Installing from Sedona Python source

Clone Sedona GitHub source code and run the following command

cd python
python3 -m pip install .

Optional dependencies

An extra installs additional packages for a particular use case. Choose the extras you need:

Package or extra Additional packages Use case
apache-sedona shapely, attrs Base package; use with an existing Spark installation.
spark pyspark Install PySpark when it is not already available.
pydeck-map geopandas, pydeck Create maps with SedonaPyDeck.
kepler-map geopandas, keplergl Create maps with SedonaKepler.
flink apache-flink Use Sedona with PyFlink.
db sedonadb[geopandas] Install SedonaDB with GeoPandas support; requested only on Python 3.9 or later.
all pyspark, geopandas, pydeck, keplergl, rasterio Install Spark, mapping, and Python raster dependencies together.

For example, to install the all extra:

pip install "apache-sedona[all]"

Despite its name, all does not include the flink or db extra. Extras also do not install the Sedona JVM jars described below.

The rasterio package supports Python-side raster objects. SQL readers for existing raster files do not require it.

On a managed Spark platform such as EMR, keep the platform's PySpark installation. To add both mapping libraries without requesting PySpark, combine the mapping extras:

pip install "apache-sedona[pydeck-map,kepler-map]"

GeoPandas brings in pandas as a dependency. PyArrow is also needed for Arrow-based conversions and pandas-on-Spark APIs; the spark and all extras do not explicitly request it. Install versions of pandas and pyarrow compatible with your Spark version when using these APIs. See working with GeoPandas and Shapely for conversion examples.

Prepare sedona-spark jar

Sedona Python needs one additional jar file called sedona-spark-shaded or sedona-spark to work properly. Please make sure you use the correct version for Spark and Scala.

Please use Spark major.minor version number in artifact names.

You can get it using one of the following methods:

  1. If you run Sedona in Databricks, AWS EMR, or other cloud platform's notebook, use the shaded jar: Download sedona-spark-shaded jar and geotools-wrapper jar from Maven Central, and put them in SPARK_HOME/jars/ folder.
  2. If you run Sedona in an IDE or a local Jupyter notebook, use the unshaded jar. Call the Maven Central coordinate in your python program. For example, Sedona >= 1.4.1
from sedona.spark import *

config = (
    SedonaContext.builder()
    .config(
        "spark.jars.packages",
        "org.apache.sedona:sedona-spark-3.5_2.12:1.9.1,"
        "org.datasyslab:geotools-wrapper:1.9.1-33.5",
    )
    .config(
        "spark.jars.repositories",
        "https://artifacts.unidata.ucar.edu/repository/unidata-all",
    )
    .getOrCreate()
)
sedona = SedonaContext.create(config)

Sedona < 1.4.1

SedonaRegistrator is deprecated in Sedona 1.4.1 and later versions. Please use the above method instead.

from pyspark.sql import SparkSession
from sedona.spark import SedonaRegistrator
from sedona.spark import SedonaKryoRegistrator, KryoSerializer

spark = (
    SparkSession.builder.appName("appName")
    .config("spark.serializer", KryoSerializer.getName)
    .config("spark.kryo.registrator", SedonaKryoRegistrator.getName)
    .config(
        "spark.jars.packages",
        "org.apache.sedona:sedona-spark-shaded-3.5_2.12:1.9.1,"
        "org.datasyslab:geotools-wrapper:1.9.1-33.5",
    )
    .getOrCreate()
)
SedonaRegistrator.registerAll(spark)

Setup environment variables

If you manually copy the sedona-spark-shaded jar to SPARK_HOME/jars/ folder, you need to setup two environment variables

  • SPARK_HOME. For example, run the command in your terminal
export SPARK_HOME=~/Downloads/spark-3.0.1-bin-hadoop2.7
  • PYTHONPATH. For example, run the command in your terminal
export PYTHONPATH=$SPARK_HOME/python

You can then play with Sedona Python Jupyter notebook.