Imports a file from Object Storage Service (OSS), MinIO, or Hadoop Distributed File System (HDFS) into a database.
Syntax
raster ST_ImportFrom(cstring chunkTableName,
cstring url,
cstring storageOption default '{}',
cstring importOption default '{}');Parameters
| Parameter | Description |
| chunkTableName | The name of the chunk table. The name must comply with the naming conventions of database tables. |
| url | The path of the external file. For more information about how to construct the path, see ST_CreateRast. |
| storageOption | A JSON string that specifies the storage information of the raster object. |
| importOption | A JSON string that specifies the import options. |
storageOption parameters are described as follows:
| Parameter | Type | Default value | Description |
| chunking | boolean | true | Specifies whether to use chunked storage. |
| chunkdim | string | Same as the raw data | The dimension information of the chunks. Format: (w, h, b). Note This parameter takes effect only when chunking=true. |
| compression | string | lz4 | The type of the compression algorithm. Valid values:
Default: lz4 |
| quality | integer | 75 | The compression quality. This parameter takes effect only for the jpeg and jp2k compression algorithms. |
| interleaving | string | Same as the raw data | The interleaving method. Valid values:
|
| blockendian | string | 'NDR' | The byte order of the chunk storage. Valid values:
|
| celltype | string | Same as the raw data | The pixel type. Valid values:
|
importOption parameters are described as follows.
| Parameter | Type | Default value | Description |
| mapping_oss_file | boolean | false | Specifies whether to map the file on OSS to an in-memory file. Note When raster data is read, some drivers are not optimized for the data stored in OSS. This generates many requests with a small data volume and results in low performance. This parameter maps the entire OSS file into an in-memory object to improve performance. The total file size is set by the GUC parameter ganos.raster.memory_oss_file_max_size. |
| parallel | integer | The value of the GUC parameter ganos.parallel.degree. | Sets the degree of parallelism of the operation. Valid values: 1 to 64. |
Description
The function creates a raster object and imports an external OSS file into the object.
To obtain the supported data types, call the ST_RasterDrivers function.
Examples
-- Specify only the foreign table name and the path
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');
-- Specify the image that corresponds to a NetCDF file with a subset
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc');
-- Specify the chunk size and the compression type during the import
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 during the import
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc', '{}', '{"parallel": 4}');