to_spatial_rdd {apache.sedona} | R Documentation |
Export a Spark SQL query with a spatial column into a Sedona spatial RDD.
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
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
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")
}
[Package apache.sedona version 1.6.0 Index]