Creates a raster object and imports a file from Object Storage Service (OSS), MinIO, or Hadoop Distributed File System (HDFS) into it.
Syntax
raster ST_ImportFrom(cstring chunkTableName,
cstring url,
cstring storageOption default '{}',
cstring importOption default '{}');
Parameters
| Parameter | Description |
|---|
chunkTableName | The name of the chunk table used to store the raster object. Must comply with PolarDB table naming conventions. |
url | The URL of the source file. For the supported URL formats, see the url parameter description in . |
storageOption | A JSON string that specifies how the raster object is stored. Default: {}. See storageOption parameters. |
importOption | A JSON string that configures the import behavior. Default: {}. See importOption parameters. |
storageOption parameters
| Parameter | Type | Default | Description |
|---|
chunking | boolean | true | Specifies whether to store data as chunks. |
chunkdim | string | Same as the source data | The chunk dimensions in w,h,b format. Takes effect only when chunking is true. |
compression | string | lz4 | The compression format. Valid values: none, jpeg, zlib, png, lzo, lz4, snappy, zstd, jp2k. |
quality | integer | 75 | The image quality after compression. Valid only for the jpeg and jp2k compression formats. |
interleaving | string | Same as the source data | The band interleaving method. Valid values: bip (Band Interleaved by Pixel), bil (Band Interleaved by Line), bsq (Band Sequential). |
blockendian | string | NDR | The byte order for each chunk. Valid values: NDR (little-endian), XDR (big-endian). |
celltype | string | Same as the source data | The pixel type. Valid values: 1bb, 2bui, 4bui, 8bsi, 8bui, 16bsi, 16bui, 32bsi, 32bui, 32bf, 64bsi, 64bui, 64bf. |
importOption parameters
| Parameter | Type | Default | Description |
|---|
mapping_oss_file | boolean | false | Specifies whether to map the source file into memory before reading. Enable this option when the driver generates many small read requests from OSS, which can degrade performance. To limit the maximum size of files that can be memory-mapped, set the GUC parameter . |
parallel | integer | Value of | The degree of parallelism for the import. Valid values: 1 to 64. |
Usage notes
To check which source file formats are supported, call .
Examples
-- Import a GeoTIFF file using only the required parameters.
SELECT ST_ImportFrom('chunk_table', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');
-- Import a specific subset from a NetCDF file.
SELECT ST_ImportFrom('chunk_table', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc');
-- Import with custom chunk dimensions and no 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"}');
-- Import with a degree of parallelism of 4.
SELECT ST_ImportFrom('chunk_table', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc', '{}', '{"parallel": 4}');