This topic describes the ST_ImportFrom function. This function is used to import an Object Storage Service (OSS) object, Multi-Cloud Object Storage (MinIO) object, or Hadoop Distributed File System (HDFS) file to a raster object in Ganos.
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 table naming conventions of Ganos. |
url | The URL of the OSS object, MinIO object, or HDFS file. For more information, see Object storage paths. |
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 the import of the OSS object, MinIO object, or HDFS file. |
The following table describes the fields in the storageOption parameter.
Field | Type | Default value | Description |
chunking | boolean | true | Specifies whether to store the data of the new raster object as chunks. |
chunkdim | string | The value is the same as the value in the original configuration data. | The dimensions based on which the system chunks the data of the new raster object. Format: (w, h, b). Note This field takes effect only when you set the chunking field to true. |
compression | string | lz4 | The format in which the system compresses the data of the new raster object. Valid values:
Default value: lz4. |
quality | integer | 75 | The image quality of the new raster object after compression. This field takes effect only when you set the compression field to jpeg or jp2k. |
interleaving | string | The value is the same as the value in the original configuration data. | The method that is used to interleave the data of the new raster object. Valid values:
|
blockendian | string | 'NDR' | The sequence that is used to store the bytes in each data chunk. Valid values:
|
celltype | string | The value is the same as the value in the original configuration data. | The pixel type of the new raster object. Valid values:
|
The following table describes the fields in the importOption parameter.
Field | Type | Default value | Description |
mapping_oss_file | boolean | false | Specifies whether to map the OSS object to an in-memory file in Ganos. Note When raster data is read, some drivers do not optimize the data stored in the OSS object. As a result, a large number of requests that require a small volume of data are generated. This reduces performance. You can use this field to map the OSS object to an in-memory file in Ganos to improve performance. The maximum size of the OSS object is specified by the ganos.raster.memory_oss_file_max_size Grand Unified Configuration (GUC) parameter. |
parallel | integer | Same as the value of the ganos.parallel.degree GUC parameter. | The degree of parallelism that is allowed. Valid values: 1 to 64. |
compute_stats | boolean | false | Specifies whether to automatically calculate band statistics during the import process. |
approx | boolean | false | Specifies whether to use a sampling method. Note If this field is set to true, the statistical value is calculated in a sampling method. The result may be inaccurate. |
factor | integer | 4 | A sampling factor of n indicates that each sampling unit is composed of n pixels during the sampling process. The setting is valid only when the approx parameter is set to true. |
exclusive_nodata | boolean | true | Specifies whether to exclude nodata values. |
Description
This function is used to create a raster object and import an OSS object, a MinIO object, or an HDFS file into the created raster object.
You can obtain the supported data types by using the ST_RasterDrivers function.
Examples:
-- Specify the AccessKey ID, AccessKey secret, and endpoint in the URL of an OSS object to create a raster object.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');
-- Specify the schema.
Select ST_ImportFrom('schema.chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');
-- Specify the host and port in the URL of the MinIO object.
Select ST_ImportFrom('chunk_table', 'MIO://<ak>:<ak_secret>@10.0.0.1:443/mybucket/data/image.tif');
-- Specify the user_name parameter in the URL of the HDFS file.
Select ST_ImportFrom('chunk_table', 'HDFS://<user_name>@10.0.0.1:8020/path/image.tif');
-- Specify a Network Common Data Form (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 an HDF5 image that contains subsets.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.hdf5://ds/hcc');
-- Specify the size per chunk and the compression format in the import process.
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 import process.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc', '{}', '{"parallel": 4}');
-- Map the OSS object to an in-memory file in Ganos.
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}');
-- Automatically calculate band statistics after the import.
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif','','{"compute_stats":true}');