Skip to content

Save data to external storage

WherobotsDB has APIs that can save an entire raster column to files in a specified location.

Save In-DB Raster

Before saving, the raster type column needs to be converted to a binary format. WherobotsDB 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 WherobotsDB file storage APIs.

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

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

As Arc Grid

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

SELECT RS_AsArcGrid(raster)

As GeoTiff

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

SELECT RS_AsGeoTiff(raster)

As PNG

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

SELECT RS_AsPNG(raster)

Please refer to Raster writer docs for more details.

Save Out-DB Raster

Out-DB raster must be saved in a Havasu (Iceberg) table. For more information, please refer to the Havasu documentation. Or, users can use RS_AsInDB to convert the out-db raster to in-db raster, and then save them to files.