cuSpatial Documentation

repository·branch-25.04·Indexed 20 days ago

https://github.com/rapidsai/cuspatial

A GPU-accelerated library for vector geospatial data analysis within the RAPIDS ecosystem. It enables high-performance spatial operations such as joins, distance calculations, and trajectory analysis by integrating with cuDF and using the GeoArrow data format. The library includes cuProj, a CUDA C++ library for high-performance coordinate transformations between Coordinate Reference Systems (CRS), and provides Java bindings via cuspatial-java.

Tokens
31.7K
Snippets
98
Records
147
Agent score
71%

What's inside cuSpatial

  1. Overview of cuProj

    branch-25.04

    cuProj is a library and Python package designed for accelerated geographic and geodetic coordinate transformations on GPUs. It is capable of transforming billions of geospatial coordinates per second.

    Key characteristics:

    • Performance: Implemented in CUDA C++ for high-performance GPU execution.
    • API Compatibility: The Python API closely matches PyProj, allowing for seamless transitions between CPU and GPU workflows.
    • Current Support: Currently supports a subset of Proj transformations, specifically WGS84 (EPSG: 4326) to/from any of the 60 UTM zone transformations (EPSG: 32601-32660, 32701-32760).
  2. Overview of cuSpatial capabilities

    branch-25.04

    cuSpatial is a general-purpose, vector-based, GPU-accelerated GIS library designed for spatial computation. It provides high-performance implementations for:

    • Spatial Indexing and Joins: Accelerated point-in-polygon operations.
    • Trajectory Analysis: Trajectory identification and reconstruction.
    • Geospatial Math: Haversine distance calculations and grid projections.

    It is designed to integrate with existing Python geospatial workflows, specifically targeting performance-critical sections of code.

  3. Overview of supported cuSpatial operations

    branch-25.04

    cuSpatial provides GPU-accelerated vector geospatial operations categorized into three main areas:

    Core Spatial Functions

    • Spatial relationship queries (DE-9IM)
    • Linestring-Linestring Intersections
    • Cartesian distance (ST_Distance)
    • Haversine distance
    • Hausdorff distance
    • Spatial window filtering

    Indexing and Join Functions

    • Quadtree indexing
    • Spatial joins
    • Quadtree-based point-in-polygon
    • Quadtree-based point-to-nearest-linestring

    Trajectory Functions

    • Deriving trajectories from point location data
    • Computing distance/speed of trajectories
    • Computing spatial bounding boxes of trajectories
  4. Overview of cuProj for Coordinate Transformations

    branch-25.04

    cuProj is a GPU-accelerated library designed for high-performance geospatial coordinate transformations. It allows users to transform coordinates between different Coordinate Reference Systems (CRS), including both cartographic projections and geodetic transformations.

    Key features:

    • High Performance: Implemented in CUDA C++ to leverage GPU acceleration.
    • Python API: Provides a Python interface that closely follows the PyProj API, making it familiar to users of the standard PyProj library.
    • Current Support: At this time, cuProj supports a subset of Proj transformations, specifically WGS84 to/from UTM.
  5. Understand the cuSpatial architecture

    branch-25.04

    cuSpatial is composed of three primary layers:

    1. GPU-backed GeoDataFrame: A data structure for managing geospatial data on the GPU.
    2. Computation APIs: A set of modules organized by spatial operation categories (e.g., distance, join).
    3. Cython API layer: The interface between Python and the underlying libcuspatial C++ library, consisting of C++ bindings (.pxd files) and Cython wrappers.

    Note that GeoSeries and GeoDataFrame inherit from cudf.Series and cudf.DataFrame respectively, extending them to support GeoColumn types.

  6. What is cuProj and how is it used?

    branch-25.04
    cuProj is a library within the cuSpatial repository that provides GPU-accelerated Coordinate Reference System (CRS) transformations. As of release 23.10, it supports transformations of WGS84 coordinates to and from Universal Transverse Mercator (UTM).
  7. Understand the libcuspatial C++ API interfaces

    branch-25.04

    libcuspatial provides two distinct C++ interfaces for geospatial and spatiotemporal data processing:

    1. Column-based API: Based on libcudf data types. It represents spatial data as tables of type-erased columns. This interface is used when working with dataframes.
    2. Header-only API: Independent of libcudf. It represents data as arrays of structures (e.g., 2D points) and uses an iterator-based approach similar to the C++ Standard Template Library (STL) or Thrust. This is ideal for low-level, container-agnostic algorithms.
  8. Perform type dispatching with cudf::type_dispatcher

    branch-25.04

    Because cudf::column stores data as type-erased void* pointers in device memory, functions must perform type dispatching to reconstruct the concrete C++ type T.

    Use the cudf::type_dispatcher utility to automate mapping runtime type information (from the column's type()) to the appropriate concrete C++ type. This is a pervasive pattern in the column-based libcuspatial API to enable interoperability with type-erased systems like Python.

  9. Understand the cuSpatial C++ header-only API

    branch-25.04

    cuSpatial provides a standalone, header-only C++ API that is independent of libcudf. This API is designed for users who do not want to depend on the large libcudf library.

    Key characteristics of the header-only API:

    • Iterator and Range-based: Uses an interface similar to STL algorithms (e.g., std::transform).
    • Templated: Supports various data types for positional data (e.g., float, double) and different integer sizes for indices.
    • Flexible Iterators: By templating on iterator types, algorithms can be fused with data transformations using "fancy" iterators (like transform or counting iterators).
    • External Memory Management: Output storage is allocated by the user and passed as an output iterator, meaning the API only requires memory resources for temporary intermediate storage.
    • CUDA Integration: All APIs that run device code or allocate memory require an rmm::cuda_stream_view to specify the execution stream.
  10. Understand the libcuspatial C++ interfaces

    branch-25.04

    libcuspatial provides two distinct C++ interfaces for GPU-accelerated spatial data analysis (distance, trajectory, indexing, and joins):

    1. Generic Header-only API: This is the primary implementation layer where all algorithms reside. It uses an iterator-based approach similar to the C++ Standard Template Library (STL) or Thrust. It represents spatial data as arrays of structures (e.g., 2D points).
    2. Column-based API: This API is built on top of the header-only API and is designed for compatibility with libcudf. It represents spatial data as cuDF tables using type-erased columns.
  11. Understand the cuSpatial package structure

    branch-25.04

    The cuspatial package is organized into several subpackages:

    • core: Contains the main components of cuSpatial.
    • io: Contains I/O functions for reading and writing external data objects.
    • tests: Contains unit tests for cuSpatial.
    • utils: Contains utility functions.
    • _lib: Contains Cython APIs that wrap the C++ libcuspatial backend.

    Within the _lib folder, Cython code is structured as follows:

    • _lib/cpp/: Contains .pxd files that declare C++ APIs for use in Cython. These files should mirror the file hierarchy of cpp/include in libcuspatial.
    • _lib/: Contains .pyx files containing Cython functions that wrap the C++ APIs for Python calls.