This topic describes the ST_ImportFrom function. This function is used to import an Object Storage Service (OSS) object into a raster object in PolarDB.

Syntax

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

Parameters

Parameter Description
chunkTableName The name of the OSS object. The OSS object is a chunk table. The name must comply with the table naming conventions of PolarDB.
url The URL of the OSS object. For more information, see the description of the url parameter in ST_CreateRast.
storageOption The JSON string that is used to specify the storage information about the raster object.
importOption The JSON string that is used to configure the parameters for OSS object import.

The following table describes the parameters in storageOption.

Parameter Type Default value Description
chunking boolean true Specifies whether to store the data as chunks.
chunkdim string The default value is the same as the value for the raw data. The dimensions that are used to chunk data. Format: w, h, b.
Note This parameter takes effect only if you set the chunking parameter to true.
compression string lz4 The format that is used to compress the data of the OSS object. Valid values:
  • none
  • jpeg
  • zlib
  • png
  • lzo
  • lz4
  • snappy
  • zstd
  • jp2k
quality integer 75 The image quality of the raster object after compression. This parameter is valid only for the JPEG and JPEG 2000 compression formats.
interleaving string The default value is the same as the value for the raw data. The method that is used to interleave the data of the OSS object. Valid values:
  • bip : Band interleaved by pixel
  • bil : Band nterleaved by pixel
  • bsq : Band Sequential
blockendian string 'NDR' The sequence that is used to store the bytes in each data chunk. Valid values:
  • NDR: little endian
  • XDR: big endian
celltype string The default value is the same as the value for the raw data. The pixel type of the raster object. Valid values:
  • 1bb: 1 bit
  • 2bui: 2-bit unsigned integer
  • 4bui : 4bit unsigned integer
  • 8bs : 8bit signed integer
  • 8bui : 8bit unsigned integer
  • 16bsi : 16bit signed integer
  • 16bui : 16bit unsigned integer
  • 32bsi : 32bit signed integer
  • 32bui : 32bit unsigned integer
  • 32bf : 32bit float
  • 64bsi : 64bit signed integer
  • 64bui : 64bit unsigned integer
  • 64bf : 64bit float
The following table describes the parameters in importOption.
Parameter Type Default value Description
mapping_oss_file boolean false Specifies whether to map the OSS object to a memory object.
Note When raster data is read, some drivers do not optimize the data stored in OSS. As a result, a large number of requests that require a small volume of data are generated. This reduces performance. This parameter can map the OSS object to a memory object to improve performance. You can use the Global User Configuration (GUC) parameter ganos.raster.memory_oss_file_max_size to specify the size of the OSS object.
parallel integer Value of the GUC parameter ganos.parallel.degree The degree of parallelism. Valid values: 1 to 64.

Description

This function is used to create a raster object and import an OSS object into the created raster object.

You can use the ST_RasterDrivers function to query the data types supported by the ST_ImportFrom function. For more information about the ST_RasterDrivers function, see ST_RasterDrivers.

Examples

-- Specify only the name and path of the OSS object that you want to import.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');

-- Specify a NetCDF image that contains subsets.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc');

-- Specify the size per chunk and the compression format in the process of importing the OSS object.
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"}');

-- Specify the degree of parallelism in the process of importing the OSS object.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc', '{}', '{"parallel": 4}');