sedona_apply_spatial_partitioner: Apply a spatial partitioner to a Sedona spatial RDD.

View source: R/spatial_partitioner.R

sedona_apply_spatial_partitionerR Documentation

Apply a spatial partitioner to a Sedona spatial RDD.

Description

Given a Sedona spatial RDD, partition its content using a spatial partitioner.

Usage

sedona_apply_spatial_partitioner(
  rdd,
  partitioner = c("quadtree", "kdbtree"),
  max_levels = NULL
)

Arguments

rdd

The spatial RDD to be partitioned.

partitioner

The name of a grid type to use (currently "quadtree" and "kdbtree" are supported) or an org.apache.sedona.core.spatialPartitioning.SpatialPartitioner JVM object. The latter option is only relevant for advanced use cases involving a custom spatial partitioner.

max_levels

Maximum number of levels in the partitioning tree data structure. If NULL (default), then use the current number of partitions within rdd as maximum number of levels. Specifying max_levels is unsupported for use cases involving a custom spatial partitioner because in these scenarios the partitioner object already has its own maximum number of levels set and there is no well-defined way to override this existing setting in the partitioning data structure.

Value

A spatially partitioned SpatialRDD.

Examples

library(sparklyr)
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_dsv_to_typed_rdd(
    sc,
    location = input_location,
    delimiter = ",",
    type = "point",
    first_spatial_col_index = 1L
  )
  sedona_apply_spatial_partitioner(rdd, partitioner = "kdbtree")
}


apache.sedona documentation built on Sept. 11, 2024, 5:24 p.m.