All Products
Search
Document Center

ApsaraDB RDS:ST_ImportFrom

Last Updated:Mar 28, 2026

Creates a raster object in Ganos and imports data from an Object Storage Service (OSS) object, Multi-Cloud Object Storage (MinIO) object, or Hadoop Distributed File System (HDFS) file into it.

To check which data formats are supported, call ST_RasterDrivers.

Syntax

raster ST_ImportFrom(cstring chunkTableName,
                     cstring url,
                     cstring storageOption default '{}',
                     cstring importOption default '{}');

Parameters

ParameterDescription
chunkTableNameThe name of the chunk table. Must comply with Ganos table naming conventions.
urlThe URL of the OSS object, MinIO object, or HDFS file. For the URL format for each storage type, see Object storage paths.
storageOptionA JSON string that controls how the raster object is stored. Defaults to {}.
importOptionA JSON string that controls the import process. Defaults to {}.

storageOption fields

FieldTypeDefaultDescription
chunkingBooleantrueSpecifies whether to store raster data as chunks.
chunkdimstringSame as sourceThe chunk dimensions in (w, h, b) format. Takes effect only when chunking is true.
compressionstringlz4The compression format. Valid values: none, jpeg, zlib, png, lzo, lz4, snappy, zstd, jp2k.
qualityinteger75The image quality of the raster object after compression. Takes effect only when compression is jpeg or jp2k.
interleavingstringSame as sourceThe band interleaving method. Valid values: bip (Band Interleaved by Pixel), bil (Band Interleaved by Line), bsq (Band Sequential).
blockendianstringNDRThe byte order for data chunks. Valid values: NDR (little endian), XDR (big endian).
celltypestringSame as sourceThe pixel type of the raster object. Valid values: 1bb, 2bui, 4bui, 8bsi, 8bui, 16bsi, 16bui, 32bsi, 32bui, 32bf, 64bsi, 64bui, 64bf.

importOption fields

FieldTypeDefaultDescription
mapping_oss_fileBooleanfalseSpecifies whether to map the OSS object to an in-memory file in Ganos. Enable this when the driver generates many small read requests against OSS, which degrades performance. The maximum file size for in-memory mapping is controlled by the ganos.raster.memory_oss_file_max_size Grand Unified Configuration (GUC) parameter.
parallelintegerSame as ganos.parallel.degree GUCThe degree of parallelism during import. Valid values: 1–64.
compute_statsBooleanfalseSpecifies whether to calculate band statistics automatically during import.
approxBooleanfalseSpecifies whether to use sampling when calculating band statistics. If true, results may be less accurate.
factorinteger4The sampling factor. Each sampling unit covers n pixels. Takes effect only when approx is true.
exclusive_nodataBooleantrueSpecifies whether to exclude nodata values.

Examples

All examples use the same function signature — only the URL scheme and option values differ by storage type and use case.

Import from OSS

-- Basic import: AccessKey ID, AccessKey secret, and endpoint embedded in the URL
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif'
);

-- Import into a specific schema
SELECT ST_ImportFrom(
    'schema.chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif'
);

Import from MinIO

-- MinIO URL includes host and port
SELECT ST_ImportFrom(
    'chunk_table',
    'MIO://<ak>:<ak_secret>@10.0.0.1:443/mybucket/data/image.tif'
);

Import from HDFS

-- HDFS URL includes the username and NameNode address
SELECT ST_ImportFrom(
    'chunk_table',
    'HDFS://<user_name>@10.0.0.1:8020/path/image.tif'
);

Import files with subsets

For multi-variable formats such as NetCDF and HDF5, append the subset identifier to the URL.

-- NetCDF: append subset name after a colon
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc'
);

-- HDF5: append dataset path after ://
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.hdf5://ds/hcc'
);

Control storage layout and parallelism

-- Set chunk dimensions to 128x128 pixels with 3 bands, disable compression
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif',
    '{"chunkdim": "(128,128,3)", "compression": "none"}'  -- storageOption
);

-- Set the degree of parallelism to 4 to speed up large imports
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc',
    '{}',
    '{"parallel": 4}'  -- importOption
);

-- Map the OSS object to an in-memory file to reduce small read overhead,
-- then import in parallel with 4 workers
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc',
    '{}',
    '{"parallel": 4, "mapping_oss_file": true}'  -- importOption
);

Calculate band statistics during import

-- Automatically calculate band statistics during import
SELECT ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif',
    '',
    '{"compute_stats": true}'  -- importOption
);