### Install SedonaDB via pip and connect Source: https://sedona.apache.org/latest/blog/2026/06/19/sedonadb-040-release Install SedonaDB using pip and establish a connection with interactive mode enabled. This is the primary way to get started with the Python API. ```python # pip install --upgrade "apache-sedona[db]" import sedona.db sd = sedona.db.connect() sd.options.interactive = True ``` -------------------------------- ### Run Sedona container with default memory (Example 2) Source: https://sedona.apache.org/latest/setup/docker?q= Starts a container with default 4GB driver and executor memory using the 1.9.1 image. ```bash docker run -d -e -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 apache/sedona:1.9.1 ``` -------------------------------- ### Run Sedona container with custom memory (Example 1) Source: https://sedona.apache.org/latest/setup/docker?q= Starts a container with 6GB driver and 8GB executor memory using the latest image, in detached mode. ```bash docker run -d -e DRIVER_MEM=6g -e EXECUTOR_MEM=8g -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 apache/sedona:latest ``` -------------------------------- ### SQL Example: ParseAddress with Output Source: https://sedona.apache.org/latest/api/sql/Address-Functions/ParseAddress?q= This example demonstrates the ParseAddress SQL function, returning an array of label-value pairs for the input address. The output shows the parsed components such as house number, road, city, state, and postal code. Requires at least 2 GB of free disk space for libpostal data, and on Windows you must manually install libpostal and libjpostal. ```sql SELECT ParseAddress("100 W 1st St, Los Angeles, CA 90012"); ``` ```text [{house_number, 100}, {road, w 1st st}, {city, los angeles}, {state, ca}, {postcode, 90012}] ``` -------------------------------- ### Example Glue notebook first cell with Sedona config Source: https://sedona.apache.org/latest/setup/glue If using the example notebook from Glue, the first cell should look like this, including the Sedona config and the standard Glue imports and context setup. ```python %idle_timeout 2880 %glue_version 5.0 %worker_type G.1X %number_of_workers 5 # Sedona Config %extra_jars https://repo1.maven.org/maven2/org/apache/sedona/sedona-spark-shaded-3.5_2.12/1.9.1/sedona-spark-shaded-3.5_2.12-1.9.1.jar, https://repo1.maven.org/maven2/org/datasyslab/geotools-wrapper/1.9.1-33.5/geotools-wrapper-1.9.1-33.5.jar %additional_python_modules apache-sedona==1.9.1 import sys from awsglue.transforms import * from awsglue.utils import getResolvedOptions from pyspark.context import SparkContext from awsglue.context import GlueContext from awsglue.job import Job sc = SparkContext.getOrCreate() glueContext = GlueContext(sc) spark = glueContext.spark_session job = Job(glueContext) ``` -------------------------------- ### Run Sedona container with persistent /opt volume (Example 3) Source: https://sedona.apache.org/latest/setup/docker?q= Starts a container with a Docker volume mounted at /opt to persist Jupyter and Zeppelin data. ```bash docker run -d -e DRIVER_MEM=6g -e EXECUTOR_MEM=8g \ -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 \ -v sedona_opt:/opt \ apache/sedona:latest ``` -------------------------------- ### Run Sedona container with default memory (Example 2) Source: https://sedona.apache.org/latest/setup/docker Starts a container with default 4GB driver and executor memory using the Sedona 1.9.1 image. Note: the command includes an extra '-e' flag before the port mappings. ```bash docker run -d -e -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 apache/sedona:1.9.1 ``` -------------------------------- ### Run Sedona container with custom memory (Example 1) Source: https://sedona.apache.org/latest/setup/docker Starts a container with 6GB driver memory and 8GB executor memory using the latest image. Runs in detached mode and binds the specified ports. ```bash docker run -d -e DRIVER_MEM=6g -e EXECUTOR_MEM=8g -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 apache/sedona:latest ``` -------------------------------- ### ST_X example output Source: https://sedona.apache.org/latest/api/flink/Geometry-Accessors/ST_X?q= The output of the example query is 0.0. ```text 0.0 ``` -------------------------------- ### Run Sedona container with persistent /opt volume (Example 3) Source: https://sedona.apache.org/latest/setup/docker Starts a container with custom memory and mounts a Docker volume named 'sedona_opt' to /opt to persist Jupyter and Zeppelin data. ```bash docker run -d -e DRIVER_MEM=6g -e EXECUTOR_MEM=8g \ -p 8888:8888 -p 8080:8080 -p 8081:8081 -p 4040:4040 -p 8085:8085 \ -v sedona_opt:/opt \ apache/sedona:latest ``` -------------------------------- ### ST_BingTileAt example output Source: https://sedona.apache.org/latest/api/flink/Spatial-Indexing/ST_BingTileAt?q= The output of the example query is the quadkey string '123030123010121'. ```text 123030123010121 ``` -------------------------------- ### Example for creating GeoDataFrame with Point and LineString Source: https://sedona.apache.org/latest/api/pydocs/_modules/sedona/spark/geopandas/geodataframe.html Shows the initial imports and GeoDataFrame creation for a second example, using Point and LineString geometries. This is the beginning of an example that is not fully shown on the page. ```python >>> from shapely.geometry import Point, LineString >>> from sedona.spark.geopandas import GeoDataFrame ``` -------------------------------- ### Python: Raster width query with RS_Width and RS_Example Source: https://sedona.apache.org/latest/blog/2025/12/01/sedonadb-020-release Shows how to connect to SedonaDB and run a SQL query to get the width of the example raster. The output displays a table with a single row and column, showing the width value 64 as uint64. ```python import sedona.db sd = sedona.db.connect() sd.sql("SELECT RS_Width(RS_Example()) as width").show() # > ┌────────┐ # > │ width │ # > │ uint64 │ # > ╞════════╡ # > │ 64 │ # > └────────┘ ``` -------------------------------- ### with_basic_auth example usage Source: https://sedona.apache.org/latest/api/pydocs/_modules/sedona/spark/stac/client.html Shows example usage of the with_basic_auth method, including standard basic auth, API key as username, and method chaining. These examples are from the docstring of the with_basic_auth method. ```python # Standard basic auth client = Client.open("https://example.com/stac/v1") client.with_basic_auth("user", "pass") # API key as username (common pattern) client.with_basic_auth("api_key_xyz", "") # Method chaining df = Client.open(url).with_basic_auth(api_key, "").search(collection_id="test") ``` -------------------------------- ### Build and serve documentation via Makefile Source: https://sedona.apache.org/latest/setup/compile Use the provided Makefile to automatically set up the environment, sync dependencies, build assets, and compile the documentation. ```bash make docsbuild ``` -------------------------------- ### GeoSeries.distance example setup Source: https://sedona.apache.org/latest/api/pydocs/sedona.spark.geopandas.api.html Defines the GeoSeries s and s2 used in the distance examples, including imports and index specification. ```python >>> from sedona.spark.geopandas import GeoSeries >>> from shapely.geometry import Polygon, LineString, Point >>> s = GeoSeries( ... [ ... Polygon([(0, 0), (1, 0), (1, 1)]), ... Polygon([(0, 0), (-1, 0), (-1, 1)]), ... LineString([(1, 1), (0, 0)]), ... Point(0, 0), ... ], ... ) >>> s2 = GeoSeries( ... [ ... Polygon([(0.5, 0.5), (1.5, 0.5), (1.5, 1.5), (0.5, 1.5)]), ... Point(3, 1), ... LineString([(1, 0), (2, 0)]), ... Point(0, 1), ... ], ... index=range(1, 5), ... ) ``` -------------------------------- ### SQL ST_Buffer point examples Source: https://sedona.apache.org/latest/api/flink/Geometry-Processing/ST_Buffer?q= SQL examples demonstrating planar buffer with default and custom quad_segs style parameter. ```sql SELECT ST_Buffer(ST_GeomFromWKT('POINT(0 0)'), 10) ``` ```sql SELECT ST_Buffer(ST_GeomFromWKT('POINT(0 0)'), 10, false, 'quad_segs=2') ``` -------------------------------- ### onApplicationStart Source: https://sedona.apache.org/latest/api/scaladoc/spark/org/apache/sedona/core/monitoring/Listener.html Callback invoked when the application starts. ```APIDOC ## onApplicationStart ### Description Called when the application starts. ### Method `def onApplicationStart(applicationStart: SparkListenerApplicationStart): Unit` ### Parameters - **applicationStart** (SparkListenerApplicationStart) - Required - The event containing application start information. ### Returns `Unit` ``` -------------------------------- ### ST_YMin example query Source: https://sedona.apache.org/latest/api/flink/Bounding-Box-Functions/ST_YMin Returns the minimum Y coordinate of the given geometry. The example uses ST_GeomFromText to create a polygon and ST_YMin to get its minimum Y value. ```sql SELECT ST_YMin(ST_GeomFromText('POLYGON((0 0 1, 1 1 1, 1 2 1, 1 1 1, 0 0 1))')) ``` -------------------------------- ### Install ipykernel and enter Pipenv shell Source: https://sedona.apache.org/latest/tutorial/jupyter-notebook Installs the ipykernel package and activates the Pipenv shell, preparing the environment for Jupyter notebook kernel setup. ```bash pipenv install ipykernel pipenv shell ``` -------------------------------- ### RS_CRS WKT2 format Source: https://sedona.apache.org/latest/api/sql/Raster-Operators/RS_CRS Example of getting the CRS in WKT2 format. ```sql SELECT RS_CRS(raster, 'wkt2') FROM raster_table ``` -------------------------------- ### Initialize SedonaContext in notebook Source: https://sedona.apache.org/latest/setup/azure-synapse-analytics?q= Starts a Spark session with Sedona dependencies and required configurations. Must be run at the beginning of the notebook. ```python from sedona.spark import SedonaContext config = ( SedonaContext.builder() .config( "spark.jars.packages", "org.apache.sedona:sedona-spark-shaded-3.4_2.12-1.6.1," "org.datasyslab:geotools-wrapper-1.6.1-28.2", ) .config("spark.serializer", "org.apache.sedona.core.serde.SedonaKryoRegistrator") .config( "spark.kryo.registrator", "org.apache.sedona.core.serde.SedonaKryoRegistrator" ) .config( "spark.sql.extensions", "org.apache.sedona.viz.sql.SedonaVizExtensions,org.apache.sedona.sql.SedonaSqlExtensions", ) .getOrCreate() ) sedona = SedonaContext.create(config) ``` -------------------------------- ### ST_AsBinary example Source: https://sedona.apache.org/latest/api/flink/Geometry-Output/ST_AsBinary Converts a WKT geometry to its binary representation. The example uses ST_GeomFromWKT to create a point geometry and then applies ST_AsBinary to get the WKB output. ```sql SELECT ST_AsBinary(ST_GeomFromWKT('POINT (1 1)')) ``` ```text 0101000000000000000000f87f000000000000f87f ``` -------------------------------- ### Setup Pipenv Python version Source: https://sedona.apache.org/latest/tutorial/jupyter-notebook?q= Navigate to the docs/usecases directory and initialize a Pipenv environment with Python 3.8. ```bash cd docs/usecases pipenv --python 3.8 ``` -------------------------------- ### Example output of downloaded packages Source: https://sedona.apache.org/latest/setup/azure-synapse-analytics Example output showing the packages that pip downloaded, including apache_sedona, shapely, rasterio, affine, cligj, and click_plugins. ```text Downloading apache_sedona-1.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (177 kB) Downloading shapely-2.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB) Downloading rasterio-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB) Downloading affine-2.4.0-py3-none-any.whl (15 kB) Downloading cligj-0.7.2-py3-none-any.whl (7.1 kB) Downloading click_plugins-1.1.1-py2.py3-none-any.whl (7.5 kB) ``` -------------------------------- ### ST_YMax example query Source: https://sedona.apache.org/latest/api/flink/Bounding-Box-Functions/ST_YMax?q= Returns the maximum Y coordinate of the given polygon geometry. The example uses ST_GeomFromText to create a polygon and ST_YMax to get its maximum Y coordinate. ```sql SELECT ST_YMax(ST_GeomFromText('POLYGON((0 0 1, 1 1 1, 1 2 1, 1 1 1, 0 0 1))')) ``` ```text 2 ``` -------------------------------- ### Example: Using approx_count with a shapefile Source: https://sedona.apache.org/latest/api/rdocs/reference/approx_count.html Complete example that loads a shapefile into a typed RDD and calls `approx_count` to get the approximate record count. The example connects to Spark, reads a shapefile as polygons, and computes the approximate count. ```r library(sparklyr) #> #> Attaching package: ‘sparklyr’ #> The following object is masked from ‘package:stats’: #> #> filter library(apache.sedona) sc <- spark_connect(master = "spark://HOST:PORT") if (!inherits(sc, "test_connection")) { input_location <- "/dev/null" # replace it with the path to your input file rdd <- sedona_read_shapefile_to_typed_rdd( sc, location = input_location, type = "polygon" ) approx_cnt <- approx_count(rdd) } ``` -------------------------------- ### Build assets and serve documentation with mike Source: https://sedona.apache.org/latest/setup/compile After installing MkDocs and MkDocs-Material, run these commands in the Sedona root folder to build the docs-overrides assets and serve the website locally using mike. ```bash cd docs-overrides && npm ci && npx gulp build cd .. uv run mike deploy --update-aliases latest-snapshot -b website -p uv run mike serve -b website ``` -------------------------------- ### Initialize SedonaContext with configuration Source: https://sedona.apache.org/latest/setup/azure-synapse-analytics Starts a SedonaContext with required Spark configurations for Sedona 1.6.1, including the shaded jar, geotools wrapper, Kryo serializer, SedonaViz/SedonaSql extensions, and creates the Sedona instance. ```python from sedona.spark import SedonaContext config = ( SedonaContext.builder() .config( "spark.jars.packages", "org.apache.sedona:sedona-spark-shaded-3.4_2.12-1.6.1," "org.datasyslab:geotools-wrapper-1.6.1-28.2", ) .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") .config( "spark.kryo.registrator", "org.apache.sedona.core.serde.SedonaKryoRegistrator" ) .config( "spark.sql.extensions", "org.apache.sedona.viz.sql.SedonaVizExtensions,org.apache.sedona.sql.SedonaSqlExtensions", ) .getOrCreate() ) sedona = SedonaContext.create(config) ``` -------------------------------- ### SQL Example: ST_MMin Source: https://sedona.apache.org/latest/api/flink/Bounding-Box-Functions/ST_MMin?q= Returns the minimum M coordinate of the given geometry. The example uses ST_GeomFromWKT to create a LINESTRING ZM and then ST_MMin to get the minimum M value, which is -1.0. ```sql SELECT ST_MMin( ST_GeomFromWKT('LINESTRING ZM(1 1 1 1, 2 2 2 2, 3 3 3 3, -1 -1 -1 -1)') ) ``` -------------------------------- ### Output of UDF bufferLength example Source: https://sedona.apache.org/latest/tutorial/sql?q= Shows the output of the UDF example, displaying the original geometry, distance, buffered geometry, and length columns. ```text +------------------------------+--------+--------------------------------------------------+-----------------+ | geom|distance| buffedGeom| length| +------------------------------+--------+--------------------------------------------------+-----------------+ |POLYGON ((1 1, 1 2, 2 1, 1 1))| 10.0|POLYGON ((1 -9, -0.9509032201612866 -8.80785280...|66.14518337329191| +------------------------------+--------+--------------------------------------------------+-----------------+ ``` -------------------------------- ### RS_CRS WKT1 format Source: https://sedona.apache.org/latest/api/sql/Raster-Operators/RS_CRS Example of getting the CRS in WKT1 format, with sample output. ```sql SELECT RS_CRS(raster, 'wkt1') FROM raster_table ``` ```text GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]] ``` -------------------------------- ### Install and connect to SedonaDB with Python Source: https://sedona.apache.org/latest/blog/2026/06/19/sedonadb-040-release?q= Install the apache-sedona package with the db extra using pip, then import sedona.db and create a connection. Enabling interactive mode is shown. ```python # pip install --upgrade "apache-sedona[db]" import sedona.db sd = sedona.db.connect() sd.options.interactive = True ``` -------------------------------- ### Install SedonaPyDeck with pydeck-map extra Source: https://sedona.apache.org/latest/tutorial/sql?q= Installs apache-sedona with the 'pydeck-map' extra to enable SedonaPyDeck functionality. This is required before using SedonaPyDeck APIs. ```bash pip install apache-sedona[pydeck-map] ``` -------------------------------- ### Example OSM PBF DataFrame for ways Source: https://sedona.apache.org/latest/tutorial/sql?q= Example output of the DataFrame for ways, showing columns id, kind, location, tags, refs, ref_roles, and ref_types. ```text +-------+----+--------+--------------------+--------------------+---------+---------+ | id|kind|location| tags| refs|ref_roles|ref_types| +-------+----+--------+--------------------+--------------------+---------+---------+ |4307329| way| NULL|{junction -> roun...|[2448759046, 7093...| NULL| NULL| |4307330| way| NULL|{surface -> aspha...|[26063923, 260639...| NULL| NULL| |4308966| way| NULL|{sidewalk -> sepa...|[3387797238, 9252...| NULL| NULL| |4308968| way| NULL|{surface -> pavin...|[26083890, 744724...| NULL| NULL| |4308969| way| NULL|{cycleway:both ->...|[9526831176, 1218...| NULL| NULL| +-------+----+--------+--------------------+--------------------+---------+---------+ ``` -------------------------------- ### GeoSeries.is_valid_reason example Source: https://sedona.apache.org/latest/api/pydocs/sedona.spark.geopandas.api.html Shows how to get the reason for invalidity of each geometry, including for missing geometries. ```python >>> from sedona.spark.geopandas import GeoSeries >>> from shapely.geometry import Polygon >>> s = GeoSeries( ... [ ... Polygon([(0, 0), (1, 1), (0, 1)]), ... Polygon([(0,0), (1, 1), (1, 0), (0, 1)]), # bowtie geometry ... Polygon([(0, 0), (2, 2), (2, 0)]), ... Polygon([(0, 0), (2, 0), (1, 1), (2, 2), (0, 2), (1, 1), (0, 0)]), ... None ... ] ... ) >>> s 0 POLYGON ((0 0, 1 1, 0 1, 0 0)) 1 POLYGON ((0 0, 1 1, 1 0, 0 1, 0 0)) 2 POLYGON ((0 0, 2 2, 2 0, 0 0)) 3 None dtype: geometry ``` ```python >>> s.is_valid_reason() 0 Valid Geometry 1 Self-intersection at or near point (0.5, 0.5, NaN) 2 Valid Geometry 3 Ring Self-intersection at or near point (1.0, 1.0) 4 None dtype: object ``` -------------------------------- ### Client.open with basic auth and method chaining Source: https://sedona.apache.org/latest/api/pydocs/_modules/sedona/spark/stac/client.html Shows example usage of Client.open with and without authentication, including basic auth and method chaining. The examples are from the docstring of the open method. ```python # Without authentication client = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1") # With custom headers client = Client.open( "https://example.com/stac/v1", headers={"Authorization": "Bearer token123"} ) # Using convenience methods client = Client.open("https://example.com/stac/v1") client.with_basic_auth("username", "password") ``` -------------------------------- ### Example OSM PBF DataFrame for nodes Source: https://sedona.apache.org/latest/tutorial/sql?q= Example output of the DataFrame for nodes, showing columns id, kind, location, tags, refs, ref_roles, and ref_types. ```text +---------+----+--------------------+--------------------+----+---------+---------+ | id|kind| location| tags|refs|ref_roles|ref_types| +---------+----+--------------------+--------------------+----+---------+---------+ |248675410|node|{21.0884952545166...|{tactile_paving -...|NULL| NULL| NULL| |260821820|node|{21.0195023191553...|{created_by -> JOSM}|NULL| NULL| NULL| |349665123|node|{22.1437530517578...|{source -> http:/...|NULL| NULL| NULL| |353366899|node|{22.9787712097167...|{source -> http:/...|NULL| NULL| NULL| |359460224|node|{22.4816703796386...|{source -> http:/...|NULL| NULL| NULL| +---------+----+--------------------+--------------------+----+---------+---------+ only showing top 5 rows ``` -------------------------------- ### def init(configuration: Configuration): WriteContext Source: https://sedona.apache.org/latest/api/scaladoc/spark/org/apache/spark/sql/execution/datasources/geoparquet/GeoParquetWriteSupport.html Initializes the write support with the given configuration and returns a WriteContext. ```APIDOC ## def init(configuration: Configuration): WriteContext ### Description Initializes the write support with the given configuration and returns a WriteContext. ### Parameters - **configuration** (Configuration) - Required - The configuration for the write operation. ### Returns - **WriteContext** - The write context for the operation. ``` -------------------------------- ### ST_EndPoint example Source: https://sedona.apache.org/latest/api/flink/Geometry-Accessors/ST_EndPoint Returns the last point of the linestring geometry. The example uses ST_GeomFromText to create a linestring and ST_EndPoint to get its last point, producing the point POINT(160 170). ```sql SELECT ST_EndPoint(ST_GeomFromText('LINESTRING(100 150,50 60, 70 80, 160 170)')) ``` ```text POINT(160 170) ``` -------------------------------- ### Sample output of gLocal Source: https://sedona.apache.org/latest/tutorial/sql Example output table showing the resulting columns: geometry, val, weights, G, EG, VG, Z, and P for each point. ```text +-----------+---+--------------------+-------------------+-------------------+--------------------+--------------------+--------------------+ | geometry|val| weights| G| EG| VG| Z| P| +-----------+---+--------------------+-------------------+-------------------+--------------------+--------------------+--------------------+ |POINT (2 2)|0.9|[{{POINT (2 3), 1...| 0.4488188976377953|0.45454545454545453| 0.00356321373799772|-0.09593402008347063| 0.4617864875295957| |POINT (2 3)|1.2|[{{POINT (2 2), 0...|0.35433070866141736|0.36363636363636365|0.003325666155464539|-0.16136436037034918| 0.4359032175415549| |POINT (3 3)|1.2|[{{POINT (2 3), 1...|0.28346456692913385| 0.2727272727272727|0.002850570990398176| 0.20110780337013057| 0.42030714022155924| |POINT (3 2)|1.2|[{{POINT (2 2), 0...| 0.4488188976377953|0.45454545454545453| 0.00356321373799772|-0.09593402008347063| 0.4617864875295957| |POINT (3 1)|1.2|[{{POINT (3 2), 3...| 0.3622047244094489| 0.2727272727272727|0.002850570990398176| 1.6758983614177538| 0.04687905137429871| |POINT (2 1)|2.2|[{{POINT (2 2), 0...| 0.4330708661417323|0.36363636363636365|0.003325666155464539| 1.2040263812249166| 0.11428969105925013| |POINT (1 1)|1.2|[{{POINT (2 1), 5...| 0.2834645669291339| 0.2727272727272727|0.002850570990398176| 0.20110780337013057| 0.42030714022155924| |POINT (1 2)|0.2|[{{POINT (2 2), 0...|0.35433070866141736|0.45454545454545453| 0.00356321373799772| -1.67884535146075|0.046591093685710794| |POINT (1 3)|1.2|[{{POINT (2 3), 1...| 0.2047244094488189| 0.2727272727272727|0.002850570990398176| -1.2736827546774914| 0.10138793530151635| |POINT (0 2)|1.0|[{{POINT (1 2), 7...|0.09448818897637795|0.18181818181818182|0.002137928242798632| -1.8887168824332323|0.029464887612748458| |POINT (4 2)|1.2|[{{POINT (3 2), 3...| 0.1889763779527559|0.18181818181818182|0.002137928242798632| 0.15481285921583854| 0.43848442662481324| +-----------+---+--------------------+-------------------+-------------------+--------------------+--------------------+--------------------+ ``` -------------------------------- ### Example OSM PBF DataFrame for relations Source: https://sedona.apache.org/latest/tutorial/sql?q= Example output of the DataFrame for relations, showing columns id, kind, location, tags, refs, ref_roles, and ref_types. ```text +-----+--------+--------+--------------------+--------------------+--------------------+--------------------+ | id| kind|location| tags| refs| ref_roles| ref_types| +-----+--------+--------+--------------------+--------------------+--------------------+--------------------+ |28124|relation| NULL|{official_name ->...|[26382394, 26259985]| [inner, outer]| [WAY, WAY]| |28488|relation| NULL| {type -> junction}|[26409253, 303249...|[roundabout, roun...|[WAY, WAY, WAY, WAY]| |32939|relation| NULL|{ref -> E 67, rou...|[140673970, 14067...| [, , , , , ]|[WAY, WAY, RELATI...| |34387|relation| NULL|{note -> rząd III...|[209161000, 52154...|[main_stream, mai...|[WAY, WAY, WAY, W...| |34392|relation| NULL|{distance -> 1047...|[150033976, 25076...|[main_stream, mai...|[WAY, WAY, WAY, W...| +-----+--------+--------+--------------------+--------------------+--------------------+--------------------+ ``` -------------------------------- ### ST_XMax example with ST_GeomFromText Source: https://sedona.apache.org/latest/api/flink/Bounding-Box-Functions/ST_XMax Returns the maximum X coordinate of a polygon geometry. The example uses ST_GeomFromText to create a polygon and then applies ST_XMax to get the maximum X coordinate, which is 2. ```sql SELECT ST_XMax(ST_GeomFromText('POLYGON ((-1 -11, 0 10, 1 11, 2 12, -1 -11))')) ``` ```text 2 ``` -------------------------------- ### def init(configuration: Configuration): WriteContext Source: https://sedona.apache.org/latest/api/scaladoc/spark/org/apache/spark/sql/execution/datasources/geoparquet/GeoParquetWriteSupport.html Initializes the write support with the given configuration and returns a WriteContext. ```APIDOC ## def init(configuration: Configuration): WriteContext ### Description Initializes the write support with the given configuration and returns a WriteContext. ### Method init ### Signature ```scala def init(configuration: Configuration): WriteContext ``` ### Parameters - **configuration** (Configuration) - Required - The configuration for the write operation. ### Returns - **WriteContext** - The write context for the operation. ### Definition Classes GeoParquetWriteSupport → WriteSupport ``` -------------------------------- ### Create map using SedonaKepler Source: https://sedona.apache.org/latest/tutorial/sql?q= Creates an interactive map visualization using SedonaKepler's create_map API. The example passes a grouped SedonaDataFrame and a name for the map. ```python SedonaKepler.create_map(df=groupedresult, name="AirportCount") ``` -------------------------------- ### GeoSeries UDF example Source: https://sedona.apache.org/latest/tutorial/sql?q= Example of a vectorized UDF that takes a GeoSeries and returns a buffered GeoSeries. Use this when you need to operate on entire GeoSeries for better performance. ```python import geopandas as gpd from sedona.spark import sedona_vectorized_udf, SedonaUDFType from sedona.spark import GeometryType @sedona_vectorized_udf(udf_type=SedonaUDFType.GEO_SERIES, return_type=GeometryType()) def vectorized_geo_series_buffer(series: gpd.GeoSeries) -> gpd.GeoSeries: buffered = series.buffer(0.1) return buffered ``` -------------------------------- ### main(String[] args) Source: https://sedona.apache.org/latest/api/javadoc/spark/org/apache/sedona/core/showcase/EarthdataMapperRunnableExample.html The main method that serves as the entry point for the example. ```APIDOC ## main(String[] args) ### Description The main method that serves as the entry point for the example. ### Method main ### Parameters - **args** (String[]) - Required - The arguments ### Returns void ``` -------------------------------- ### ST_Envelope example query Source: https://sedona.apache.org/latest/api/flink/Bounding-Box-Functions/ST_Envelope Returns the envelope boundary of the input geometry. The example uses ST_GeomFromWKT to create a LINESTRING and ST_Envelope to get its bounding box. The output is a POLYGON representing the envelope. ```sql SELECT ST_Envelope(ST_GeomFromWKT('LINESTRING(0 0, 1 3)')) ``` -------------------------------- ### Java: Load JDBC data with query and dbtable options Source: https://sedona.apache.org/latest/tutorial/sql?q= Two Java examples for loading spatial data from JDBC. The first uses the 'query' option with ST_AsBinary for any JDBC source. The second uses 'dbtable' for PostGIS. Both convert the geometry column using ST_GeomFromWKB. ```java // For any JDBC data source, including Postgis. Dataset df = sedona.read().format("jdbc") // Other options. .option("query", "SELECT id, ST_AsBinary(geom) as geom FROM my_table") .load() .withColumn("geom", expr("ST_GeomFromWKB(geom)")) // This is a simplified version that works for Postgis. Dataset df = sedona.read().format("jdbc") // Other options. .option("dbtable", "my_table") .load() .withColumn("geom", expr("ST_GeomFromWKB(geom)")) ``` -------------------------------- ### DBSCAN output example Source: https://sedona.apache.org/latest/tutorial/sql?q= Sample output from the DBSCAN function showing the geometry, id, isCore flag, and cluster assignment. Points with cluster -1 are noise. ```text +----------------+---+------+-------+ | geometry| id|isCore|cluster| +----------------+---+------+-------+ | POINT (2.5 4)| 3| false| 1| | POINT (3 4)| 2| false| 1| | POINT (3 5)| 5| false| 1| | POINT (1 3)| 9| true| 0| | POINT (2.5 4.5)| 7| true| 1| | POINT (1 2)| 1| true| 0| | POINT (1.5 2.5)| 4| true| 0| | POINT (1.2 2.5)| 8| true| 0| | POINT (1 2.5)| 11| true| 0| | POINT (1 5)| 10| false| -1| | POINT (5 6)| 12| false| -1| |POINT (12.8 4.5)| 6| false| -1| | POINT (4 3)| 13| false| -1| +----------------+---+------+-------+ ``` -------------------------------- ### Python: Load JDBC data with query and dbtable options Source: https://sedona.apache.org/latest/tutorial/sql?q= Two Python examples for loading spatial data from JDBC. The first uses the 'query' option with ST_AsBinary for any JDBC source. The second uses 'dbtable' for PostGIS. Both convert the geometry column using ST_GeomFromWKB. ```python # For any JDBC data source, including Postgis. df = (sedona.read.format("jdbc") # Other options. .option("query", "SELECT id, ST_AsBinary(geom) as geom FROM my_table") .load() .withColumn("geom", f.expr("ST_GeomFromWKB(geom)"))) # This is a simplified version that works for Postgis. df = (sedona.read.format("jdbc") # Other options. .option("dbtable", "my_table") .load() .withColumn("geom", f.expr("ST_GeomFromWKB(geom)"))) ``` -------------------------------- ### RS_CRS PROJ string format Source: https://sedona.apache.org/latest/api/sql/Raster-Operators/RS_CRS Example of getting the CRS in PROJ string format, with sample output. ```sql SELECT RS_CRS(raster, 'proj') FROM raster_table ``` ```text +proj=longlat +datum=WGS84 +no_defs +type=crs ``` -------------------------------- ### Create heatmap using SedonaPyDeck Source: https://sedona.apache.org/latest/tutorial/sql?q= Visualizes a heatmap from a SedonaDataFrame containing points using the create_heatmap API. The example uses the Chicago crimes dataset. ```python SedonaPyDeck.create_heatmap(df=crimes_df) ``` -------------------------------- ### RS_AsImage SQL example with output Source: https://sedona.apache.org/latest/api/sql/Raster-Output/RS_AsImage?q= SQL example showing RS_AsImage with and without the imageWidth parameter, followed by the HTML output string it returns. ```sql SELECT RS_AsImage(raster, 500) from rasters SELECT RS_AsImage(raster) from rasters ``` ```text ""; ``` -------------------------------- ### RS_CRS default PROJJSON format Source: https://sedona.apache.org/latest/api/sql/Raster-Operators/RS_CRS Example of getting the CRS in default PROJJSON format, with sample output. ```sql SELECT RS_CRS(raster) FROM raster_table ``` ```json { "$schema": "https://proj.org/schemas/v0.7/projjson.schema.json", "type": "GeographicCRS", "name": "WGS 84", ... } ``` -------------------------------- ### Estimate UTM CRS example with geodatasets and geopandas Source: https://sedona.apache.org/latest/api/pydocs/_modules/sedona/spark/geopandas/geoseries.html Example usage of estimate_utm_crs() on a GeoSeries read from a geodatasets file. Requires 'pip install geodatasets'. The output shows the derived projected CRS (EPSG:32616) with details about the UTM zone and datum. ```python >>> import geodatasets # requires: pip install geodatasets >>> import geopandas as gpd >>> df = gpd.read_file( ... geodatasets.get_path("geoda.chicago_commpop") ... ) >>> df.geometry.values.estimate_utm_crs() # doctest: +SKIP Name: WGS 84 / UTM zone 16N Axis Info [cartesian]: - E[east]: Easting (metre) - N[north]: Northing (metre) Area of Use: - name: Between 90°W and 84°W, northern hemisphere between equator and 84°N,... - bounds: (-90.0, 0.0, -84.0, 84.0) Coordinate Operation: - name: UTM zone 16N - method: Transverse Mercator Datum: World Geodetic System 1984 ensemble - Ellipsoid: WGS 84 - Prime Meridian: Greenwich ``` -------------------------------- ### Create scatterplot map using SedonaPyDeck Source: https://sedona.apache.org/latest/tutorial/sql?q= Visualizes a scatterplot from a SedonaDataFrame containing points using the create_scatterplot_map API. The example uses the Chicago crimes dataset. ```python SedonaPyDeck.create_scatterplot_map(df=crimes_df) ``` -------------------------------- ### Connect to SedonaDB Source: https://sedona.apache.org/latest/blog/2026/03/01/sedonadb-030-release Install the SedonaDB package and establish a connection. The interactive option enables a more interactive experience. ```python # pip install "apache-sedona[db]" import sedona.db sd = sedona.db.connect() sd.options.interactive = True ``` -------------------------------- ### Get geometry type of a polygon (SQL) Source: https://sedona.apache.org/latest/api/sql/geography/Geography-Functions/ST_GeometryType Example SQL query using ST_GeometryType with a polygon expressed in WKT. It returns the string 'ST_Polygon'. ```sql SELECT ST_GeometryType(ST_GeogFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')); ``` ```plain text ST_Polygon ``` -------------------------------- ### ST_PointN(geometry, n) Source: https://sedona.apache.org/latest/api/pydocs/_modules/sedona/spark/sql/st_functions.html Gets the n-th point (1-based) from a geometry. Negative indices start from the end, and out-of-bounds indices return null. ```APIDOC ## ST_PointN(geometry, n) ### Description Gets the n-th point (1-based) from a geometry. Negative indices start from the end, and out-of-bounds indices return null. ### Parameters - **geometry** (ColumnOrName) - Required - Geometry column to get the point from. - **n** (Union[ColumnOrName, int]) - Required - Index for the point to return, 1-based, negative values start from the end so -1 is the last point, values that are out of bounds return null. ### Returns - **Column** - n-th point from the geometry as a point geometry column, or null if index is out of bounds. ``` -------------------------------- ### Method: initPartition() Source: https://sedona.apache.org/latest/api/javadoc/spark/org/apache/sedona/core/joinJudgement/RightIndexLookupJudgement.html Initializes the partition by looking up the extent of the current partition. ```APIDOC ## Method: initPartition ### Description Initializes the partition by looking up the extent of the current partition. ### Method initPartition ### Signature ```java protected void initPartition() ``` ### Parameters None ### Returns void ``` -------------------------------- ### Install SedonaDB with pip Source: https://sedona.apache.org/latest/blog/2025/09/24/introducing-sedonadb-a-single-node-analytical-database-engine-with-geospatial-as-a-first-class-citizen?q= Install the SedonaDB package with the 'db' extra using pip. ```bash pip install "apache-sedona[db]" ``` -------------------------------- ### Scala: Load JDBC data with query and dbtable options Source: https://sedona.apache.org/latest/tutorial/sql?q= Two Scala examples for loading spatial data from JDBC. The first uses the 'query' option with ST_AsBinary to convert geometry for any JDBC source. The second uses 'dbtable' for PostGIS, which already uses EWKB. Both convert the geometry column using ST_GeomFromWKB. ```scala // For any JDBC data source, including Postgis. val df = sedona.read.format("jdbc") // Other options. .option("query", "SELECT id, ST_AsBinary(geom) as geom FROM my_table") .load() .withColumn("geom", expr("ST_GeomFromWKB(geom)")) // This is a simplified version that works for Postgis. val df = sedona.read.format("jdbc") // Other options. .option("dbtable", "my_table") .load() .withColumn("geom", expr("ST_GeomFromWKB(geom)")) ``` -------------------------------- ### Shapely scalar UDF example Source: https://sedona.apache.org/latest/tutorial/sql?q= Example of a vectorized UDF that takes a Shapely BaseGeometry and returns a buffered geometry. Use this when you want to process individual geometries with Shapely operations. ```python import shapely.geometry.base as b from sedona.spark import sedona_vectorized_udf @sedona_vectorized_udf(return_type=GeometryType()) def vectorized_buffer(geom: b.BaseGeometry) -> b.BaseGeometry: return geom.buffer(0.1) ``` -------------------------------- ### Get total bounds with total_bounds Source: https://sedona.apache.org/latest/api/pydocs/sedona.spark.geopandas.api.html Computes the total bounds of a GeoDataFrame as a tuple of minx, miny, maxx, maxy. The example uses a GeoDataFrame with a CRS. ```python >>> from shapely.geometry import Point, Polygon, LineString >>> d = {'geometry': [Point(3, -1), Polygon([(0, 0), (1, 1), (1, 0)]), ... LineString([(0, 1), (1, 2)])]} >>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326") >>> gdf.total_bounds array([ 0., -1., 3., 2.]) ``` -------------------------------- ### ST_BingTilesAround example output Source: https://sedona.apache.org/latest/api/flink/Spatial-Indexing/ST_BingTilesAround Output of the example query, showing the array of quadkey strings for the 3x3 neighborhood. ```text [0, 2, 1, 3] ``` -------------------------------- ### Start Spark cluster with start-all.sh Source: https://sedona.apache.org/latest/setup/cluster?q= Run this command from the root folder of the uncompressed Apache Spark distribution to start the cluster. ```bash ./sbin/start-all.sh ``` -------------------------------- ### ST_NDims with x,y coordinate Source: https://sedona.apache.org/latest/api/flink/Geometry-Accessors/ST_NDims Returns 2 for a point with only x and y coordinates. The example uses ST_GeomFromText to create a 2D point and ST_NDims to get its dimension. ```sql SELECT ST_NDims(ST_GeomFromText('POINT(1 1)')) ``` ```text 2 ``` -------------------------------- ### Install uv and sync documentation dependencies Source: https://sedona.apache.org/latest/setup/compile Install the uv package manager and sync the documentation group dependencies, which include MkDocs and related tools. ```bash python3 -m pip install uv uv sync --group docs ```