to_spatial_rdd: Export a Spark SQL query with a spatial column into a Sedona...

Description Usage Arguments Value Examples

View source: R/spatial_rdd.R

Description

Given a Spark dataframe object or a dplyr expression encapsulating a Spark SQL query, build a Sedona spatial RDD that will encapsulate the same query or data source. The input should contain exactly one spatial column and all other non-spatial columns will be treated as custom user-defined attributes in the resulting spatial RDD.

Usage

1
to_spatial_rdd(x, spatial_col)

Arguments

x

A Spark dataframe object in sparklyr or a dplyr expression representing a Spark SQL query.

spatial_col

The name of the spatial column.

Value

A SpatialRDD encapsulating the query.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(sparklyr)
library(apache.sedona)

sc <- spark_connect(master = "spark://HOST:PORT")

if (!inherits(sc, "test_connection")) {
  tbl <- dplyr::tbl(
    sc,
    dplyr::sql("SELECT ST_GeomFromText('POINT(-71.064544 42.28787)') AS `pt`")
  )
  rdd <- to_spatial_rdd(tbl, "pt")
}

apache.sedona documentation built on Oct. 11, 2021, 9:06 a.m.