This topic describes the ST_ImportFrom function. This function is used to import an Object Storage Service (OSS) object, a Multi-Cloud Object Storage (MinIO) object, or a 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:
  • none
  • jpeg
  • zlib
  • png
  • lzo
  • lz4
  • snappy
  • zstd
  • jp2k

Default: 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:
  • bip : Band interleaved by pixel
  • bil : Band interleaved by line
  • 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 value is the same as the value in the original configuration data. The pixel type of the new raster object. Valid values:
  • 1bb: 1-bit integer
  • 2bui: 2-bit unsigned integer
  • 4bui : 4bit unsigned integer
  • 8bsi : 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 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 GUC parameter. For more information about this parameter, see ganos.raster.memory_oss_file_max_size.
parallel Integer The value of the ganos.parallel.degree GUC parameter. For more information, see ganos.parallel.degree. The degree of parallelism that is allowed. Valid values: 1 to 64.

Description

This function is used to create a raster object and import an OSS object or a MinIO object 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 host and port parameters in the URL of the MinIO object.
Select ST_ImportFrom('chunk_table', 'MIO://<ak>:<ak_secret>@10.0.XX.XX: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.XX.XX: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 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}');