Skip to content

Save data to external storage

Sedona has APIs that can save an entire raster column to files in a specified location. Before saving, the raster type column needs to be converted to a binary format. Sedona provides several functions to convert a raster column into a binary column suitable for file storage. Once in binary format, the raster data can then be written to files on disk using the Sedona file storage APIs.

rasterDf.write.format("raster").option("rasterField", "raster").option("fileExtension", ".tiff").mode(SaveMode.Overwrite).save(dirPath)

Sedona has a few writer functions that create the binary DataFrame necessary for saving the raster images.

As Arc Grid

Use RS_AsArcGrid to get binary Dataframe of raster in Arc Grid format.

SELECT RS_AsArcGrid(raster)

As GeoTiff

Use RS_AsGeoTiff to get binary Dataframe of raster in GeoTiff format.

SELECT RS_AsGeoTiff(raster)


Use RS_AsPNG to get binary Dataframe of raster in PNG format.

Please refer to Raster writer docs for more details.

Performance optimization

When working with large raster datasets, refer to the documentation on storing raster geometries in Parquet format for recommendations to optimize performance.

Last update: December 21, 2023 21:56:22