> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Save Raster 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.

```sparksql theme={"system"}
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](/reference/wherobots-db/raster-data/output/RS_AsArcGrid) to get the binary Dataframe of the raster in Arc Grid format.

```sql theme={"system"}
SELECT RS_AsArcGrid(raster)
```

### As GeoTiff

Use [RS\_AsGeoTiff](/reference/wherobots-db/raster-data/output/RS_AsGeoTiff) to get the binary Dataframe of the raster in GeoTiff format.

```sql theme={"system"}
SELECT RS_AsGeoTiff(raster)
```

### As PNG

Use [RS\_AsPNG](/reference/wherobots-db/raster-data/output/RS_AsPNG) to get the binary Dataframe of the raster in PNG format.

```sql theme={"system"}
SELECT RS_AsPNG(raster)
```

Please refer to [Raster writer docs](/reference/wherobots-db/raster-data/raster-writer) 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](./havasu). Or, users can use [`RS_AsInDB`](/reference/wherobots-db/raster-data/constructors/RS_AsInDB) to convert the out-db raster to in-db raster, and then save them to files.
