Sedona writers are available in Scala. Java and Python have the same APIs.
Write Raster DataFrame to raster files
To write a Sedona Raster DataFrame to raster files, you need to (1) first convert the Raster DataFrame to a binary DataFrame usingRS_AsXXX functions and (2) then write the binary DataFrame to raster files using Sedona’s built-in raster data source.
Write raster DataFrame to a binary DataFrame
You can use the following RS output functions (RS_AsXXX) to convert a Raster DataFrame to a binary DataFrame. Generally the output format of a raster can be different from the original input format. For example, you can use RS_FromGeoTiff to create rasters and save them using RS_AsArcGrid.
| Function | Description |
|---|---|
| RS_AsGeoTiff | Convert a raster to GeoTiff binary format |
| RS_AsArcGrid | Convert a raster to Arc Info ASCII Grid binary format |
| RS_AsPNG | Convert a raster to PNG binary format |
Write a binary DataFrame to raster files
Introduction: You can write a Sedona binary DataFrame to external storage using Sedona’s built-inraster data source. Note that: raster data source does not support reading rasters. Please use Spark built-in binaryFile and Sedona RS constructors together to read rasters.
Available options:
- rasterField:
- Default value: the
binarytype column in the DataFrame. If the input DataFrame has several binary columns, please specify which column you want to use. You can use one of theRS_As*functions mentioned above to convert the raster objects to binary raster file content to write. - Allowed values: the name of the to-be-saved binary type column
- Default value: the
- fileExtension
- Default value:
.tiff - Allowed values: any string values such as
.png,.jpeg,.asc
- Default value:
- pathField
- No default value. If you use this option, then the column specified in this option must exist in the DataFrame schema. If this option is not used, each produced raster image will have a random UUID file name.
- Allowed values: any column name that indicates the paths of each raster file
- useDirectCommitter
- Default value:
true. If set totrue, the output files will be written directly to the target location. If set tofalse, the output files will be written to a temporary location and finally be committed to their target location. It is usually slower to write large amount of raster files withuseDirectCommitterset tofalse, especially when writing to object stores such as S3. - Allowed values:
trueorfalse
- Default value:
* in the path):
RS_FromGeoTiff(content) (if the written data was in GeoTiff format).
The newly created DataFrame can be written to disk again but must be under a different name such as my_raster_file_modified
Write Geometry to Raster dataframe
You can use RS_AsRaster to convert a Geometry to a Raster dataset. UnlikeRS_Clip, which extracts a subset of an existing raster while preserving its original values, RS_AsRaster generates a new Raster where the Geometry is rasterized onto a raster grid.
