This function creates a raster object based on Object Storage Service (OSS).

Syntax

raster ST_CreateRast(cstring url);
raster ST_CreateRast(cstring url, cstring storageOption);
raster ST_CreateRast(anyarray data , integer width, cstring storageOption, geometry extent);

Parameters

ParameterDescription
urlThe path of the OSS object based on which you want to create a raster object. For more information, see Object storage paths.
storageOptionA JSON string that describes the chunks for storing the pyramid of the raster object.
dataThe raster represented by a one-dimensional array. The number of elements in the one-dimensional array is the product of the number of columns and the number of rows of the raster.
widthThe number of columns of the raster.
extentThe three-dimensional space represented by using a geometry. This parameter is optional.

The following table describes the fields of the storageOption parameter.

FieldDescriptionTypeFormatDefault valueDescription
chunkdimThe size of each chunk that is used to store the data of the raster object.String(w, h, b)Same as the size of each chunk in the original objectNone
interleavingThe interleaving type of the raster object.StringNonebsqValid values:
  • bip: band interleaved by pixel (BIP)
  • bil: band interleaved by line (BIL)
  • bsq: band sequential (BSQ)
  • auto: an interleaving method that is specified by this function
chunk_tableThe name of the chunk table that you want to specify.StringNoneNoneIf you want to call this function to generate a raster object by using the raster object represented by a specified one-dimensional array, you must specify this parameter.
Note You need to change the default values of the chunkdim and interleaving fields only in some cases:
  • Users want to view the raster object based on multiband red, green, and blue (RGB) combination, but the value of the interleaving field is bsq. In this case, you must change the value of the interleaving field to bip.
  • The chunks of some images that are used to render the raster object contain 1 row and n columns in size. However, users request chunks that contain 256 rows and 256 columns in size. In this case, you must change the value of the chunkdim field to the requested chunk size.

Description

You can specify the path of the OSS object in the following format: oss://access_id:secrect_key@Endpoint/path_to/file. The endpoint is optional. If you do not specify the endpoint, the system finds the endpoint and you must make sure that the path starts with a forward slash (/).

The endpoint is the domain name that you can use to access the OSS bucket where the OSS object is stored. For the best import performance, make sure that the AnalyticDB for PostgreSQL instance resides in the same region as the OSS bucket. For more information, see OSS Endpoint.

Examples

-- Specify the AccessKey ID, AccessKey secret, and endpoint in the URL of an OSS object to create a raster object.
Select ST_CreateRast('OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');

-- Specify the host and port parameters in the URL of a MinIO bucket to create a raster object.
Select ST_CreateRast('OSS://<ak>:<ak_secret>@10.0.XX.XX:443/mybucket/data/image.tif');

-- Specify the user_name parameter in the URL of an HDFS file.
Select ST_CreateRast('HDFS://<user_name>@10.0.XX.XX:8020/path/image.tif');

-- Specify the chunkdim and interleaving parameters of a raster object.
Select ST_CreateRast('OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif', '{"chunkdim":"(256,256,3)","interleaving":"auto"}');

-- Specify a NetCDF image that contains subsets.
Select ST_CreateRast('OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc');
            
-- Generate a raster object from an array.
select ST_FixedRid(ST_CreateRast(ARRAY[10, 11, 8, 12], 2, '{"chunktable":"rbt"}',ST_GeomFromText('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))', 4326)));

-- Use array_agg to aggregate multiple records to generate a raster object.
select ST_FixedRid(ST_CreateRast((select array_agg(value) from point_table), 300, '{"chunktable":"rbt"}'));