This topic describes the ST_ExportTo function. This function is used to export a raster object as an Object Storage Service (OSS) object, a Multi-Cloud Object Storage (MinIO) object, or a Hadoop Distributed File System (HDFS) file.

Syntax

boolean ST_ExportTo(raster source,
  cstring format,
  cstring url,
  integer level = 0);

Parameters

Parameter Description
source The raster object that you want to export.
format The format of the exported data, such as GTiff or BMP.
url The URL of the exported OSS object, MinIO object, or HDFS file. This function does not support an URL that specifies a subset. For more information, see Object storage paths.
level The pyramid level.
The format parameter specifies the format of the exported data. The following table lists common formats.
Format Full name
BMP Microsoft Windows Device Independent Bitmap(.bmp)
ECW ERDAS Compressed Wavelets (.ecw)
EHdr ESRI .hdr Labelled
GIF Graphics InterchangeFormat(.gif)
GPKG GeoPackage
GTiff TIFF/BigTIFF/GeoTIFF(.tif)
HDF4 Hierarchical Data Format Release 4 (HDF4)
PDF Geospatial PDF
PNG Portable Network Graphics (.png)
COG Cloud optimized GeoTIFF

Description

If the raster object is exported, the function returns true. If the raster object fails to be exported, the function returns false.

You can obtain the supported data types by using the ST_RasterDrivers function.

Examples

-- Export a raster object as an OSS object.
Select ST_ExportTo(raster, 'GTiff', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif')
from raster_table
where id=1;

-- Export a raster object as a MinIO object.
Select ST_ExportTo(raster, 'PNG', 'MIO://<ak>:<ak_secret>@10.0.XX.XX:443/mybucket/data/image.png')
from raster_table
where id=1;

-- Export a raster object as an HDFS file.
Select ST_ExportTo(raster, 'PNG', 'HDFS://<user_name>@10.0.XX.XX:8020/path/image.png')
from raster_table
where id=1;