Save a Spark dataframe containing exactly 1 spatial column into a file.
Source:R/data_interface.R
sedona_save_spatial_rdd.Rd
Export serialized data from a Spark dataframe containing exactly 1 spatial column into a file.
Usage
sedona_save_spatial_rdd(
x,
spatial_col,
output_location,
output_format = c("wkb", "wkt", "geojson")
)
See also
Other Sedona RDD data interface functions:
sedona_read_dsv_to_typed_rdd()
,
sedona_read_geojson()
,
sedona_read_shapefile_to_typed_rdd()
,
sedona_write_wkb()
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`")
)
sedona_save_spatial_rdd(
tbl %>% dplyr::mutate(id = 1),
spatial_col = "pt",
output_location = "/tmp/pts.wkb",
output_format = "wkb"
)
}