All Products
Search
Document Center

ApsaraDB RDS:ST_AsTile

Last Updated:Apr 23, 2024

This topic describes the ST_AsTile function. This function crops a 256 or 512 pixel-sized tile from a raster object and converts the tile into a binary stream based on the file format.

Syntax

record ST_AsTile(raster raster_obj, geometry geom, cstring export_options default '');

Return values

A record that includes the following fields is returned:

  • ext: the image format.

  • data: a bytea that represents a 256 or 512 pixel-sized tile.

Parameters

Parameter

Description

raster_obj

The input grid object.

geom

The geometric object that represents a tile range.

export_options

The output options.

Usage notes

The following table describes the options that you can configure for the export_options parameter.

Option

Description

Type

Default Value

Comment

bands

The output bands. Separate multiple output bands with commas (,).

cstring

''

By default, full bands are returned.

format

The format of the output image.

cstring

PNG

The PNG, JPEG, and GTiff formats are supported.

pyramid_level

The pyramid level.

integer

-1

By default, the optimal band is selected.

dim

The pixel size of the output tile.

integer

256

Valid values: 256 and 512.

nodata

Specifies whether to consider the nodata value.

boolean

true

If you do not specify this option, the nodata value of the object is used.

nodatavalue

The nodata value.

f8

0

This option is valid only if you set the nodata option to true.

strength

Specifies whether to implement enhancement in the display.

string

none

Valid values:

  • none: Enhancement is not implemented.

  • stats: Enhancement is implemented by using stretching based on statistical values.

  • ratio: Enhancement is implemented by using stretching based on ratios.

ratio_offset

The percentage offset.

integer

2

Enhancement is implemented by using stretching based on the percentage of n to 100-n.

alpha

Specifies whether to add an alpha channel to implement the transparency effect.

boolean

false

-

quality

The quality of the compression.

integer

75

Valid values: 0 to 100. The value 0 indicates the poorest compression quality, and the value 100 indicates the optimal compression quality.

Examples

SELECT ST_AsTile(rast, ST_GeomFromText('POLYGON((-80 30,-100 30, -100 100, -80 100, -80 30))',4326),'{"format":"PNG","bands":"0,1,2"}') FROM raster_table;

SELECT ST_AsTile(rast, ST_GeomFromText('POLYGON((-80 30,-100 30, -100 100, -80 100, -80 30))',4326),'{"format":"GTiff","bands":"0,1,2","pyramid_level":7}') FROM raster_table;