### Install Libraries and Public Headers (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Installs the gpuspatial and gpuspatial_c libraries, along with OptiX, to the appropriate installation directories. Also installs public headers. ```cmake install(TARGETS gpuspatial gpuspatial_c OptiX EXPORT gpuspatial-exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### Install SedonaDB Expr Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb-expr/README.md Use pip to install the package. ```shell pip install sedonadb-expr ``` -------------------------------- ### Clone and Run SedonaDB Rust Example Source: https://github.com/apache/sedona-db/blob/main/examples/sedonadb-rust/README.md Clone the SedonaDB repository, navigate to the Rust example directory, and run the example using Cargo. ```shell git clone https://github.com/apache/sedona-db.git cd sedona-db/examples/sedona-rust cargo run ``` -------------------------------- ### Install Rust on Windows Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Download and execute the rustup installer via PowerShell. ```powershell Invoke-WebRequest https://sh.rustup.rs -UseBasicParsing -OutFile rustup-init.exe .\rustup-init.exe # Restart PowerShell rustc --version cargo --version ``` -------------------------------- ### Install CMake Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/README.md Download and install CMake from the official releases. This command installs it to the user's local directory. ```bash wget https://github.com/Kitware/CMake/releases/download/v3.31.8/cmake-3.31.8-linux-x86_64.sh bash cmake-3.31.8-linux-x86_64.sh --prefix=$HOME/.local --exclude-subdir --skip-license ``` -------------------------------- ### Install OptiX Headers (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Installs the OptiX headers to the system's include directory during the installation phase. ```cmake install(DIRECTORY ${optix_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### Install documentation dependencies Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Install required Python packages for building the documentation. ```sh pip install -r docs/requirements.txt ``` -------------------------------- ### Quick Start with SedonaDB Source: https://github.com/apache/sedona-db/blob/main/README.md Basic initialization and execution of a spatial SQL query. ```python import sedona.db # Connect to SedonaDB sd = sedona.db.connect() # Run a simple spatial query result = sd.sql("SELECT ST_Point(0, 1) as geom") result.show() ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/apache/sedona-db/blob/main/docs/README.md Clone the SedonaDB repository and install the necessary Python packages for local development. The optional step installs the test dependencies for the latest dev version. ```shell git clone https://github.com/apache/sedona-db.git && cd sedona-db # OPTIONAL: build the doc for the latest dev version of sedona-db pip install -e "python/sedonadb/[test]" -vv pip install -r docs/requirements.txt ``` -------------------------------- ### Install gpuspatial Public Headers (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Installs the public headers from the 'include/gpuspatial/' directory to the installation's include path. ```cmake install(DIRECTORY include/gpuspatial/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gpuspatial) ``` -------------------------------- ### Connect and Query Source: https://github.com/apache/sedona-db/blob/main/docs/quickstart-python.ipynb Initialize a connection to SedonaDB and execute a basic SQL query to verify the installation. ```python import sedona.db sd = sedona.db.connect() sd.sql("SELECT ST_Point(0, 1) as geom").show() ``` -------------------------------- ### Install SedonaDB Source: https://github.com/apache/sedona-db/blob/main/README.md Commands to install the SedonaDB package using pip or conda. ```sh pip install "apache-sedona[db]" ``` ```sh conda install sedonadb ``` -------------------------------- ### Connect to SedonaDB Source: https://github.com/apache/sedona-db/blob/main/docs/geopandas-interop.ipynb Establishes a connection to SedonaDB. Ensure SedonaDB is installed with the 'db' extra: `pip install "apache-sedona[db]"`. ```python import sedona.db import geopandas as gpd sd = sedona.db.connect() ``` -------------------------------- ### Install Required Dependencies Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.ipynb Install necessary packages for data handling and spatial benchmarking. ```bash !pip install huggingface_hub rasterio pyogrio ``` -------------------------------- ### Link libgpuspatial in CMakeLists.txt Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/README.md Example CMakeLists.txt configuration to find and link the installed libgpuspatial library to a custom executable. It also defines a preprocessor macro for the shader path. ```cmake # User's CMakeLists.txt find_package(gpuspatial REQUIRED) add_executable(my_app main.cpp) # Link to gpuspatial target_link_libraries(my_app PRIVATE gpuspatial::gpuspatial) # Pass the shader path to the C++/CUDA code target_compile_definitions(my_app PRIVATE GPUSPATIAL_SHADER_PATH="${gpuspatial_SHADER_DIR}" ) ``` -------------------------------- ### Query Macro Benchmark Setup in Default Mode Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Use this setup for macro benchmarks representing end-user performance. Engines should run with their natural, multi-threaded configuration. ```python import pytest from sedonadb.testing import SedonaDB, DuckDB, PostGIS @pytest.mark.parametrize("eng", [SedonaDB, PostGIS, DuckDB]) def test_knn_performance(benchmark, eng): ... ``` -------------------------------- ### Install libraries with vcpkg Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Use vcpkg to install the required native libraries for the project. ```powershell C:\dev\vcpkg\vcpkg.exe install geos gdal proj abseil openssl ``` -------------------------------- ### Install sedonafns from GitHub Source: https://github.com/apache/sedona-db/blob/main/r/sedonafns/README.md Use the pak package to install the development version of sedonafns from the apache/sedona-db repository. ```r # install.packages("pak") pak::pak("apache/sedona-db/r/sedonafns") ``` -------------------------------- ### Install dependencies on Linux Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Use apt-get to install required build tools and libraries on Ubuntu/Debian systems. ```shell sudo apt-get install -y build-essential cmake libssl-dev libproj-dev libgeos-dev libgdal-dev python3-dev libabsl-dev ``` -------------------------------- ### Install SedonaDB via pip Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb/README.md Use this command to install the SedonaDB package from PyPI. ```shell pip install "apache-sedona[db]" ``` -------------------------------- ### Install SedonaDB with Test Dependencies Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Install SedonaDB in release mode, including test dependencies. Avoid debug mode for benchmarks. This command ensures all necessary packages for testing are available. ```bash pip install "python/sedonadb[test]" ``` -------------------------------- ### Start PostGIS Docker Container Source: https://github.com/apache/sedona-db/blob/main/docs/postgis.ipynb Starts a PostGIS Docker container for development and testing purposes. ```bash docker compose up postgis --detach ``` -------------------------------- ### Install Python development environment Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Commands to install the Python bindings in editable mode with test dependencies. ```bash cd python/sedonadb pip install -e ".[test]" ``` -------------------------------- ### Connect to SedonaDB Source: https://github.com/apache/sedona-db/blob/main/docs/delta-lake.ipynb Establishes a connection to SedonaDB. Ensure 'deltalake' is installed via pip. ```python from deltalake import write_deltalake, DeltaTable import sedona.db import pyarrow.compute as pc sd = sedona.db.connect() ``` -------------------------------- ### Install Shader Files (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Installs the compiled PTX shader files to a specific directory within the installation path. ```cmake set(GPUSPATIAL_SHADER_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/gpuspatial/shaders") install(FILES ${PTX_FILES} DESTINATION ${GPUSPATIAL_SHADER_INSTALL_DIR}) ``` -------------------------------- ### Install Apache Arrow Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/README.md Download, extract, and build Apache Arrow with specific configurations for S3, Parquet, IPC, Filesystem, and Snappy support. The installation path is set to the user's local directory. ```bash wget "https://github.com/apache/arrow/releases/download/apache-arrow-20.0.0/apache-arrow-20.0.0.tar.gz" sudo apt install libcurl4-openssl-dev libzstd-dev # dependencies for S3 support and NanoArrow tar zxvf apache-arrow-20.0.0.tar.gz cd apache-arrow-20.0.0/cpp mkdir build && cd build INSTALL_PATH=$HOME/.local cmake -DARROW_S3=ON \ -DARROW_PARQUET=ON \ -DARROW_IPC=ON \ -DARROW_FILESYSTEM=ON \ -DARROW_WITH_SNAPPY=ON \ -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" \ -DCMAKE_BUILD_TYPE=Release \ .. make -j$(nproc) make install ``` -------------------------------- ### Install pre-commit via pip Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Installs the pre-commit tool if it is not already present in the environment. ```shell pip install pre-commit ``` -------------------------------- ### Install pytest-benchmark Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Install the pytest-benchmark package using pip. This is a prerequisite for running the benchmarks. ```bash pip install pytest-benchmark ``` -------------------------------- ### Install SedonaDB with R Source: https://github.com/apache/sedona-db/blob/main/docs/index.md Use this command to install SedonaDB for R programming language. ```r install.packages("sedonadb", repos = "https://community.r-multiverse.org") ``` -------------------------------- ### Install dependencies on Linux Source: https://github.com/apache/sedona-db/blob/main/dev/release/README.md Use conda to create an environment and install required build tools and libraries. ```shell conda create -y --name verify-sedona-db conda activate verify-sedona-db conda install -y compilers curl gnupg geos proj openssl libabseil cmake make pkg-config "gdal<3.13" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CONDA_PREFIX/lib" ``` -------------------------------- ### Install Dependencies Source: https://github.com/apache/sedona-db/blob/main/docs/postgis.ipynb Installs necessary Python packages for PostGIS and SedonaDB integration in a Jupyter environment. ```bash pip install geopandas sqlalchemy geoalchemy2 psycopg2-binary adbc-driver-postgresql ``` -------------------------------- ### Install dependencies on macOS Source: https://github.com/apache/sedona-db/blob/main/dev/release/README.md Use Homebrew to install required system dependencies. ```shell brew install geos proj openssl abseil ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Initializes pre-commit hooks to ensure code formatting and quality checks pass during CI. ```shell pre-commit install ``` -------------------------------- ### Install sedonadb Development Version from GitHub Source: https://github.com/apache/sedona-db/blob/main/r/sedonadb/README.md Install the latest development version of the sedonadb package directly from its GitHub repository using the pak package manager. This method requires a Rust compiler and GEOS system dependency. ```r pak::pkg_install("apache/sedona-db/r/sedonadb") ``` -------------------------------- ### Example SQL function usage Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md SQL snippet for demonstrating function usage in documentation. ```sql SELECT ST_FunctionName(ST_Point(0, 1)) AS val; ``` -------------------------------- ### UDF Micro Benchmark Setup in Single-Thread Mode Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Use this setup for micro benchmarks measuring per-function cost. Ensure engines are configured for single-thread operation where possible. ```python import pytest from sedonadb.testing import SedonaDBSingleThread, DuckDBSingleThread, PostGISSingleThread @pytest.mark.parametrize("eng", [SedonaDBSingleThread, PostGISSingleThread, DuckDBSingleThread]) def test_st_area(benchmark, eng): ... ``` -------------------------------- ### Install Python package with GPU support Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.md Use this command to enable GPU features during the build process from source. ```bash MATURIN_PEP517_ARGS="--features='gpu,s2geography,pyo3/extension-module' pip install" ``` -------------------------------- ### Install SedonaDB Zarr dependencies Source: https://github.com/apache/sedona-db/blob/main/docs/working-with-zarr-ndarray-sedonadb.ipynb Install the core SedonaDB package along with the Zarr and expression extensions, and optional visualization tools. ```bash pip install "apache-sedona[db]" sedonadb-zarr sedonadb-expr lonboard ``` -------------------------------- ### Check SedonaDB Expr Version Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb-expr/README.md Import the package and print its version to verify installation. ```python import sedonadb_expr print(sedonadb_expr.__version__) ``` -------------------------------- ### Install SedonaDB via conda Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb/README.md Use this command to install the SedonaDB package using the conda package manager. ```sh conda install sedonadb ``` -------------------------------- ### Run Prebuilt GPU-Enabled Docker Image Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.ipynb Starts a JupyterLab instance with GPU support using the official SedonaDB Docker image. ```bash docker run -it --rm --gpus all -p 8888:8888 apache/sedona:sedonadb-latest ``` -------------------------------- ### Write OpenSSL Libraries to File Source: https://github.com/apache/sedona-db/blob/main/c/sedona-s2geography/CMakeLists.txt Creates a file named `openssl_libraries.txt` in the binary directory, listing all OpenSSL libraries found. This file is then installed. ```cmake file(TOUCH "${CMAKE_BINARY_DIR}/openssl_libraries.txt") foreach(lib ${OPENSSL_LIBRARIES}) file(APPEND "${CMAKE_BINARY_DIR}/openssl_libraries.txt" "${lib}\n") endforeach() install(FILES "${CMAKE_BINARY_DIR}/openssl_libraries.txt" DESTINATION "${CMAKE_INSTALL_LIBDIR}") ``` -------------------------------- ### Verify CMake installation on Windows Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Check the installed version of CMake to ensure it is correctly added to the system PATH. ```powershell cmake --version ``` -------------------------------- ### Query Overture Buildings Source: https://github.com/apache/sedona-db/blob/main/README.md Example workflow for connecting to a dataset, reading Parquet files, and performing spatial filtering. ```python import sedona.db sd = sedona.db.connect() ``` ```python df = sd.read_parquet( "s3://overturemaps-us-west-2/release/2026-02-18.0/theme=buildings/type=building/", options={"aws.skip_signature": True, "aws.region": "us-west-2"}, ) df.to_view("buildings") ``` ```python nyc_bbox_wkt = ( "POLYGON((-74.2591 40.4774, -74.2591 40.9176, -73.7004 40.9176, -73.7004 40.4774, -74.2591 40.4774))" ) sd.sql(f""" SELECT id, height, num_floors, roof_shape, ST_Centroid(geometry) as centroid FROM buildings WHERE is_underground = FALSE AND height IS NOT NULL AND height > 20 AND ST_Intersects(geometry, ST_GeomFromText('{nyc_bbox_wkt}', 4326)) LIMIT 5; """).show() ``` -------------------------------- ### Install s2 Library Export Set Source: https://github.com/apache/sedona-db/blob/main/c/sedona-s2geography/CMakeLists.txt Installs the `s2` library and its export set if s2geometry was built from the subdirectory. This makes the `s2` library available for other projects that depend on it. ```cmake if(S2_BUILT_FROM_SUBDIRECTORY) install(TARGETS s2 EXPORT "s2geography-targets" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Manage PostGIS container Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Commands to start, stop, and access the PostGIS instance required for Python tests. ```shell docker compose up -d ``` ```shell docker compose down ``` ```shell docker compose exec postgis psql -U postgres ``` -------------------------------- ### Create Point Geometry with SRID Source: https://github.com/apache/sedona-db/blob/main/docs/crs-examples.ipynb Example of creating a POINT geometry and directly specifying its SRID using ST_Point. ```sql SELECT ST_Point(-8238310.24, 4969803.3, 3857); ``` -------------------------------- ### Build Documentation with Script Source: https://github.com/apache/sedona-db/blob/main/docs/README.md Execute the provided script to build the documentation. This script is useful for initial local builds and ensures all necessary steps are followed. ```shell ci/scripts/build-docs.sh ``` -------------------------------- ### Run a SQL query with Python Source: https://github.com/apache/sedona-db/blob/main/docs/index.md Connect to SedonaDB and execute a SQL query using the Python API. Requires the 'apache-sedona[db]' installation. ```python import sedona.db sd = sedona.db.connect() sd.sql("SELECT ST_Point(0, 1) as geom") ``` -------------------------------- ### Spatial Join with Memory Management Configuration Source: https://github.com/apache/sedona-db/blob/main/docs/memory-management.ipynb Example of configuring memory limit, pool type, and temporary directory before performing a spatial join. All runtime options must be set before the internal context is initialized. ```python import sedona.db sd = sedona.db.connect() # Optionally override runtime options before any sd.sql(...) or sd.read_* call. sd.options.memory_limit = "4gb" sd.options.memory_pool_type = "fair" sd.options.temp_dir = "/tmp/sedona-spill" ``` -------------------------------- ### SedonaDB Rust Query Output Source: https://github.com/apache/sedona-db/blob/main/examples/sedonadb-rust/README.md Example output from a basic query executed using SedonaDB and DataFusion in Rust, showing city names and their corresponding WKT geometries. ```text +-------------+----------------------------------------------+ | name | geometry | +-------------+----------------------------------------------+ | Abidjan | POINT(-4.020206835187587 5.3231260722445715) | | Abu Dhabi | POINT(54.3665934 24.4666836) | | Abuja | POINT(7.489505042885861 9.054620406360845) | | Accra | POINT(-0.2186616 5.5519805) | | Addis Ababa | POINT(38.6980586 9.0352562) | +-------------+----------------------------------------------+ ``` -------------------------------- ### Initialize SedonaDB Context and Load Datasets Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.ipynb Connect to the SedonaDB instance and define external tables for spatial data. ```python import sedonadb ctx = sedonadb.connect() ctx.options.memory_limit = "unlimited" ctx.sql(""" CREATE EXTERNAL TABLE zone STORED AS PARQUET LOCATION 'hf-data/v0.1.0/sf1/zone/' """) ctx.sql(""" CREATE EXTERNAL TABLE trip STORED AS PARQUET LOCATION 'hf-data/v0.1.0/sf1/trip/' """).execute() ``` -------------------------------- ### Render documentation with Quarto Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Command to render the SQL reference documentation. ```shell cd docs/reference/sql quarto render ``` -------------------------------- ### Set Up PyIceberg Catalog Source: https://github.com/apache/sedona-db/blob/main/docs/iceberg.md Initializes the PyIceberg catalog using a SQLite database for metadata and a file-based warehouse. Configure the catalog type, URI, and warehouse path. ```python warehouse_path = "/tmp/warehouse" catalog = load_catalog( "default", **{ "type": "sql", "uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db", "warehouse": f"file://{warehouse_path}", }, ) ``` -------------------------------- ### MkDocs Development Server and Build Commands Source: https://github.com/apache/sedona-db/blob/main/docs/README.md Commands to serve the documentation locally with live reloading or to build the static documentation site. Use `mkdocs -h` for a full list of options. ```shell mkdocs serve mkdocs build mkdocs -h ``` -------------------------------- ### Export Targets for Installation (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Exports the gpuspatial targets for use by other projects when installed. ```cmake rapids_export(INSTALL gpuspatial EXPORT_SET gpuspatial-exports GLOBAL_TARGETS gpuspatial VERSION ${PROJECT_VERSION} NAMESPACE gpuspatial::) ``` -------------------------------- ### Render SQL Function Documentation with Quarto Source: https://github.com/apache/sedona-db/blob/main/docs/README.md Navigate to the SQL function documentation directory and render the project using Quarto to generate Markdown files for mkdocs. This step is necessary before building the main documentation. ```shell cd docs/reference/sql quarto render ``` -------------------------------- ### Import and Connect to SedonaDB Source: https://github.com/apache/sedona-db/blob/main/docs/working-with-parquet-files.ipynb Import the sedona.db module and establish a connection to SedonaDB. This is the initial step before performing any operations. ```python # Import the sedona.db module and connect to SedonaDB import sedona.db sd = sedona.db.connect() ``` -------------------------------- ### Initialize test submodules Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Commands to fetch required submodules containing test data and external dependencies. ```shell git submodule init git submodule update --recursive ``` -------------------------------- ### Convert sf to SedonaDB and Query Source: https://github.com/apache/sedona-db/blob/main/r/sedonadb/README.md Converts an sf object to a SedonaDB table and then queries it using SQL. Requires the sf package for initial data loading. ```r library(sf) #> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE nc <- sf::read_sf(system.file("shape/nc.shp", package = "sf")) nc |> sd_to_view("nc", overwrite = TRUE) sd_sql("SELECT * FROM nc") #> ┌─────────┬───────────┬─────────┬───┬─────────┬─────────┬────────────────────────────────────────┐ #> │ AREA ┆ PERIMETER ┆ CNTY_ ┆ … ┆ SID79 ┆ NWBIR79 ┆ geometry │ #> │ float64 ┆ float64 ┆ float64 ┆ ┆ float64 ┆ float64 ┆ geometry │ #> ╞═════════╪═══════════╪═════════╪═══╪═════════╪═════════╪════════════════════════════════════════╡ #> │ 0.114 ┆ 1.442 ┆ 1825.0 ┆ … ┆ 0.0 ┆ 19.0 ┆ MULTIPOLYGON(((-81.4727554321289 36.2… │ #> ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ #> │ 0.061 ┆ 1.231 ┆ 1827.0 ┆ … ┆ 3.0 ┆ 12.0 ┆ MULTIPOLYGON(((-81.2398910522461 36.3… │ #> ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ #> │ 0.143 ┆ 1.63 ┆ 1828.0 ┆ … ┆ 6.0 ┆ 260.0 ┆ MULTIPOLYGON(((-80.45634460449219 36.… │ #> ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ #> │ 0.07 ┆ 2.968 ┆ 1831.0 ┆ … ┆ 2.0 ┆ 145.0 ┆ MULTIPOLYGON(((-76.00897216796875 36.… │ #> ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ #> │ 0.153 ┆ 2.206 ┆ 1832.0 ┆ … ┆ 3.0 ┆ 1197.0 ┆ MULTIPOLYGON(((-77.21766662597656 36.… │ #> ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ #> │ 0.097 ┆ 1.67 ┆ 1833.0 ┆ … ┆ 5.0 ┆ 1237.0 ┆ MULTIPOLYGON(((-76.74506378173828 36.… │ #> └─────────┴───────────┴─────────┴───┴─────────┴─────────┴────────────────────────────────────────┘ #> Preview of up to 6 row(s) ``` -------------------------------- ### Count Rows in Buildings DataFrame Source: https://github.com/apache/sedona-db/blob/main/docs/crs-examples.ipynb Get the total number of records in the 'buildings' DataFrame. ```python buildings.count() ``` -------------------------------- ### Run libgpuspatial Benchmark Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/README.md Execute a libgpuspatial benchmark with specified build and stream files, execution mode, and a limit on the number of operations. ```bash ./build/benchmark -build_file wherobots-benchmark-prod/data/3rdparty-bench/postal-codes-sorted \ -stream_file wherobots-benchmark-prod/data/3rdparty-bench/osm-nodes-large-sorted-corrected \ -execution geos \ -limit 5 ``` -------------------------------- ### Show Sample Data from Buildings DataFrame Source: https://github.com/apache/sedona-db/blob/main/docs/crs-examples.ipynb Display the first few rows of the 'buildings' DataFrame to preview the spatial data. ```python buildings.show(3) ``` -------------------------------- ### Display First 5 Rows of a View Source: https://github.com/apache/sedona-db/blob/main/docs/overture-examples.ipynb Use the `.show()` method to display a specified number of rows from a SedonaDB view. This is useful for inspecting query results. ```python sd.view("divisions_ns").show(5) ``` -------------------------------- ### Ambiguous geometry reference errors Source: https://github.com/apache/sedona-db/blob/main/r/sedonadb/tests/testthat/_snaps/join-expression.md Examples of errors triggered by ambiguous geometry function calls in join conditions. ```R st_intersects(.tables$x$geom(), y$geom()) ``` ```R st_intersects(x$geom(), y$geom()) ``` -------------------------------- ### Navigate to Benchmarks Directory Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Change the current working directory to the benchmarks folder. This is where the benchmark scripts are located. ```bash cd benchmarks/ ``` -------------------------------- ### Create a SedonaDB DataFrame Source: https://github.com/apache/sedona-db/blob/main/docs/quickstart-python.ipynb Initialize a DataFrame containing string and geometry columns using SQL values. ```python df = sd.sql(""" SELECT * FROM (VALUES ('one', ST_GeomFromWkt('POINT(1 2)')), ('two', ST_GeomFromWkt('POLYGON(( -74.0 40.7, -74.0 40.8, -73.9 40.8, -73.9 40.7, -74.0 40.7 ))')), ('three', ST_GeomFromWkt('LINESTRING( -74.0060 40.7128, -73.9352 40.7306, -73.8561 40.8484 )')) ) AS t(val, point) """) ``` -------------------------------- ### Manage Python native components with Maturin Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Commands to recompile native Rust code or install the Maturin build backend. ```bash maturin develop ``` ```bash pip install maturin ``` -------------------------------- ### Define complex SQL function metadata Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Example of YAML frontmatter for a function with multiple kernel implementations and argument definitions. ```yaml --- title: ST_Buffer description: > Computes a geometry that represents all points whose distance from the input geometry is less than or equal to a specified distance. kernels: - returns: geometry args: - geometry - name: distance type: float64 description: Radius of the buffer - returns: geometry args: - geometry - name: distance type: float64 - name: params type: utf8 description: Space-separated `key=value` parameters. --- ``` -------------------------------- ### Run a SQL query with R Source: https://github.com/apache/sedona-db/blob/main/docs/index.md Execute a SQL query using the R interface for SedonaDB. Requires the 'sedonadb' package installation. ```r library(sedonadb) sd_sql("SELECT ST_Point(0, 1) as geom") ``` -------------------------------- ### Load Dependencies for PyIceberg and SedonaDB Source: https://github.com/apache/sedona-db/blob/main/docs/iceberg.md Import necessary libraries for interacting with PyIceberg, SedonaDB, PyArrow, and the operating system. ```python from pyiceberg.catalog import load_catalog import sedona.db import pyarrow as pa import os ``` -------------------------------- ### Run Rust tests and CLI Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Standard commands for executing the test suite and running the local development CLI. ```bash cargo test ``` ```bash cargo run --bin sedona-cli ``` -------------------------------- ### Bootstrap vcpkg on Windows Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Clone and bootstrap the vcpkg package manager to manage native dependencies. ```powershell git clone https://github.com/microsoft/vcpkg.git C:\dev\vcpkg cd C:\dev\vcpkg .\bootstrap-vcpkg.bat ``` -------------------------------- ### Connect and Read Data with SedonaDB Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb/README.md Establishes a connection to SedonaDB and reads a Parquet file from a URL. ```python import sedona.db sd = sedona.db.connect() sd.options.interactive = True url = "https://raw.githubusercontent.com/geoarrow/geoarrow-data/v0.2.0/natural-earth/files/natural-earth_cities_geo.parquet" sd.read_parquet(url).head(5) ``` -------------------------------- ### Build s2geometry if not found Source: https://github.com/apache/sedona-db/blob/main/c/sedona-s2geography/CMakeLists.txt If s2geometry is not found via `find_package`, this block configures and builds it from its subdirectory. It disables tests and examples for the s2geometry build. ```cmake if(NOT s2_FOUND) # Build s2geometry using its own CMake (v0.12.0 has proper add_subdirectory support). set(BUILD_TESTS OFF CACHE BOOL "" FORCE) set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) add_subdirectory(s2geometry) set(S2_BUILT_FROM_SUBDIRECTORY TRUE) else() message(STATUS "Found s2 via find_package") set(S2_BUILT_FROM_SUBDIRECTORY FALSE) endif() ``` -------------------------------- ### Unsupported: Create Temporary View with CREATE TEMP VIEW Source: https://github.com/apache/sedona-db/blob/main/docs/working-with-sql-sedonadb.md SedonaDB does not support `CREATE TEMP VIEW` or `CREATE TEMPORARY VIEW`. Attempting to use these commands will result in an error. ```python >>> sd.sql("CREATE TEMP VIEW b AS SELECT * FROM '/path/to/building.parquet'") Traceback (most recent call last): ... sedonadb._lib.SedonaError: Temporary views not supported ``` -------------------------------- ### Find Required External Dependencies Source: https://github.com/apache/sedona-db/blob/main/c/sedona-s2geography/CMakeLists.txt Finds the OpenSSL and Abseil libraries, which are required external dependencies. These should be installed via package managers like Homebrew or vcpkg. ```cmake find_package(OpenSSL REQUIRED) find_package(absl REQUIRED) ``` -------------------------------- ### Initialize Sedona DB Connection Source: https://github.com/apache/sedona-db/blob/main/r/sedonadb/tests/testthat/_snaps/context.md Set global runtime options with sd_connect() before executing your first query. Cannot change runtime options after the context has been initialized. ```R sd_connect() ``` -------------------------------- ### Run a Specific Benchmark Test Source: https://github.com/apache/sedona-db/blob/main/benchmarks/README.md Execute a single benchmark test function, for example, `test_st_buffer`. This command runs benchmarks for the specified function and test class. ```bash pytest test_functions.py::TestBenchFunctions::test_st_buffer ``` -------------------------------- ### Read Parquet file into Sedona DataFrame Source: https://github.com/apache/sedona-db/blob/main/docs/crs-examples.ipynb Load spatial data from a Parquet file into a Sedona DataFrame. This example reads building data which has a different CRS than the 'vermont' data. ```python buildings = sd.read_parquet( "https://github.com/geoarrow/geoarrow-data/releases/download/v0.2.0/microsoft-buildings_point_geo.parquet" ) ``` -------------------------------- ### Configure libgpuspatial Build Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/README.md Configure the build process for libgpuspatial using CMake. This command sets the build type to Release, specifies the installation path for dependencies, and enables tests and benchmarks. ```bash mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=$HOME/.local \ -DGPUSPATIAL_BUILD_TESTS=ON \ -DGPUSPATIAL_BUILD_BENCHMARK=ON \ .. ``` -------------------------------- ### Filter Countries by Geographic Region Source: https://github.com/apache/sedona-db/blob/main/docs/delta-lake.ipynb This example demonstrates how to filter countries within a specific geographic region using the `ST_Intersects` function. It requires defining a polygon to represent the region of interest. ```python res = sd.sql(""" SELECT name, continent, ST_GeomFromWKT(geometry_wkt) as geom FROM my_table WHERE ST_Intersects( ST_GeomFromWKT(geometry_wkt), ST_GeomFromWKT('POLYGON((-81 5, -75 5, -75 -56, -81 -56, -81 5))') ) ") res.show() ``` -------------------------------- ### Add gpuspatial_c Library (CMake) Source: https://github.com/apache/sedona-db/blob/main/c/sedona-libgpuspatial/libgpuspatial/CMakeLists.txt Creates a C wrapper library (gpuspatial_c) that links against the main gpuspatial library. ```cmake add_library(gpuspatial_c src/gpuspatial_c.cc) target_link_libraries(gpuspatial_c PUBLIC gpuspatial) ``` -------------------------------- ### Filter Buildings by Height and Location Source: https://github.com/apache/sedona-db/blob/main/docs/overture-examples.md Find buildings in New York City taller than 20 meters. This example demonstrates spatial filtering using ST_Intersects and parameter binding for the bounding box. ```python nyc_bbox_wkt = ( "POLYGON((-74.2591 40.4774, -74.2591 40.9176, -73.7004 40.9176, " "-73.7004 40.4774, -74.2591 40.4774))" ) sd.sql( """ SELECT id, height, num_floors, roof_shape, ST_Centroid(geometry) as centroid FROM buildings WHERE is_underground = FALSE AND height IS NOT NULL AND height > 20 AND ST_Intersects( geometry, ST_GeomFromText($1, 4326) ) LIMIT 5; """, params=(nyc_bbox_wkt,), ).to_memtable().to_view("buildings_nyc") ``` ```python sd.view("buildings_nyc").show(5) ``` -------------------------------- ### Verify a release candidate Source: https://github.com/apache/sedona-db/blob/main/dev/release/README.md Run the verification script with the target version and release candidate number. ```shell # git clone https://github.com/apache/sedona-db.git && cd sedona-db # or # cd existing/sedona-db && git fetch upstream && git switch main && git pull upstream main dev/release/verify-release-candidate.sh 0.3.0 0 ``` -------------------------------- ### Create Restaurants View Source: https://github.com/apache/sedona-db/blob/main/docs/programming-guide.md Creates a SQL view named 'restaurants' from a DataFrame containing restaurant names and their locations as Point geometries. ```python df = sd.sql(""" SELECT name, ST_Point(lng, lat) AS location FROM (VALUES (101, -74.0, 40.7, 'Pizza Palace'), (102, -73.99, 40.69, 'Burger Barn'), (103, -74.02, 40.72, 'Taco Town'), (104, -73.98, 40.75, 'Sushi Spot'), (105, -74.05, 40.68, 'Deli Direct') ) AS t(id, lng, lat, name) """) sd.sql("drop view if exists restaurants") df.to_view("restaurants") ``` -------------------------------- ### Get Iceberg Table Schema Source: https://github.com/apache/sedona-db/blob/main/docs/iceberg.md Retrieves and displays the schema of the loaded Arrow Table from the Iceberg table. This confirms the data types and column names, including the binary 'geometry_wkb' and double-precision 'bbox' columns. ```python arrow_table.schema ``` -------------------------------- ### Recommended: Create View using to_view() Source: https://github.com/apache/sedona-db/blob/main/docs/working-with-sql-sedonadb.md The recommended alternative to temporary views is to load data into a DataFrame and then use the `to_view()` method to register it. This is the standard practice in Spark-based environments. ```python # Step 1: Load your data into a DataFrame first >>> building_df = sd.read_parquet("/path/to/building.parquet") # Step 2: Register the DataFrame as a temporary view >>> building_df.to_view("b") # Step 3: You can now successfully query the view using SQL >>> sd.sql("SELECT * FROM b LIMIT 5").show() ``` -------------------------------- ### Register and Read Zarr Data Source: https://github.com/apache/sedona-db/blob/main/python/sedonadb-zarr/README.md Initialize the SedonaDB connection, register the Zarr extension, and load a Zarr file as a raster column. ```python import sedona.db from sedonadb_zarr import ZarrExtension sd = sedona.db.connect() sd.register(ZarrExtension()) sd.read("file:///path/to/foo.zarr").show() ``` -------------------------------- ### Upload source release Source: https://github.com/apache/sedona-db/blob/main/dev/release/README.md Use the helper script to upload the release tarball to the official Apache repository. ```shell # upload-release.sh dev/release/upload-release.sh 0.3.0 0 ``` -------------------------------- ### Clone the repository Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Downloads the forked repository to the local machine. ```shell git clone https://github.com/YourUsername/sedona-db.git cd sedona-db ``` -------------------------------- ### Create a release branch Source: https://github.com/apache/sedona-db/blob/main/dev/release/README.md Initializes a new release branch from the upstream main repository. ```shell git pull upstream main git checkout -b branch-0.3.0 git push upstream -u branch-0.3.0:branch-0.3.0 ``` -------------------------------- ### Build and push the GPU Docker image Source: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md Executes the release script to build multi-architecture images and push them to the registry. ```shell docker/build.sh release apache/sedona:sedonadb-latest ``` -------------------------------- ### Create Customers View Source: https://github.com/apache/sedona-db/blob/main/docs/programming-guide.md Creates a SQL view named 'customers' from a DataFrame containing customer names and their locations as Point geometries. ```python df = sd.sql(""" SELECT name, ST_Point(lng, lat) AS location FROM (VALUES (1, -74.0, 40.7, 'Alice'), (2, -73.9, 40.8, 'Bob'), (3, -74.1, 40.6, 'Carol') ) AS t(id, lng, lat, name) """) sd.sql("drop view if exists customers") df.to_view("customers") ``` -------------------------------- ### Show First 3 Rows of SedonaDB DataFrame Source: https://github.com/apache/sedona-db/blob/main/docs/geopandas-interop.ipynb Displays the first three rows of the SedonaDB DataFrame. Useful for quickly inspecting the data after conversion from a FlatGeobuf file. ```python df.show(3) ``` -------------------------------- ### Download Spatial Benchmark Data Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.ipynb Download required spatial datasets from Hugging Face for testing. ```python from huggingface_hub import snapshot_download snapshot_download( repo_id="apache-sedona/spatialbench", repo_type="dataset", local_dir="hf-data", allow_patterns=["v0.1.0/sf1/zone/*", "v0.1.0/sf1/trip/*"], ) ``` -------------------------------- ### Create SedonaDB DataFrame from SQL Source: https://github.com/apache/sedona-db/blob/main/docs/programming-guide.md Manually create a SedonaDB DataFrame by executing a SQL query with spatial data. Supports WKT geometry. ```python df = sd.sql(""" SELECT * FROM (VALUES ('one', ST_GeomFromWkt('POINT(1 2)')), ('two', ST_GeomFromWkt('POLYGON((-74.0 40.7, -74.0 40.8, -73.9 40.8, -73.9 40.7, -74.0 40.7))')), ('three', ST_GeomFromWkt('LINESTRING(-74.0060 40.7128, -73.9352 40.7306, -73.8561 40.8484)'))) AS t(val, point)""") ``` -------------------------------- ### Enable GPU Acceleration Source: https://github.com/apache/sedona-db/blob/main/docs/gpu-acceleration.ipynb Set the gpu.enable option to true to activate GPU spatial join capabilities. ```python import sedonadb ctx = sedonadb.connect() ctx.sql("SET gpu.enable = true").execute() ``` -------------------------------- ### Enable Spill Compression in SedonaDB Source: https://github.com/apache/sedona-db/blob/main/docs/memory-management.md Connects to SedonaDB and sets the DataFusion execution option to enable LZ4 compression for spill files. This reduces disk I/O and space usage at the cost of CPU. ```python import sedona.db sd = sedona.db.connect() # Enable LZ4 compression for spill files. sd.sql("SET datafusion.execution.spill_compression = 'lz4_frame'").execute() ```