ST_AsPng

更新时间:
复制 MD 格式

Renders a specific tile of a pyramid as a PNG image.

Syntax

bytea ST_AsPng(cstring name, cstring key, cstring style);
bytea ST_AsPng(cstring name, int x, int y, int z, cstring style);

Parameters

ParameterDescription
nameThe name of the pyramid.
keyThe tile ID in z_x_y format.
xThe x coordinate of the tile.
yThe y coordinate of the tile.
zThe z coordinate of the tile.
styleThe rendering style as a JSON string. If not specified, the default style is used.

Style fields

FieldTypeDefaultDescription
backgroundstring#FFFFFFFFThe RGBA background color. Default: white.
line_colorstring#000000FFThe RGBA color of dots and edges. Default: black.
fill_colorstring#F4A460FFThe RGBA fill color of the tile. Default: brown.
line_widthint1The line width, in pixels.
point_sizeint10The size per dot, in pixels. Default: a circle with a 10-pixel diameter.
parallel_unitint50000The number of elements each parallel task renders.

Example style:

{
  "background": "#FFFFFFFF",
  "line_color": "#000000FF",
  "fill_color": "#F4A460FF",
  "line_width": 1,
  "point_size": 10
}

Usage notes

  • The tile ID (key) uses the z_x_y format and follows the EPSG:4326 or EPSG:3857 coordinate system.

  • In EPSG:4326, a tile consists of multiple chunks, and the number of chunks on the x axis is twice the number on the y axis. The z coordinate starts from 1. When z is 1, the only valid tile IDs are 1_0_0 and 1_1_0.

  • The output PNG image size equals the tileSize value specified when the pyramid was built. For details, see ST_BuildPyramid.

Examples

Query by tile ID string:

select ST_AsPng('roads', '3_1_6', '');

Output:

st_aspng
----------
0xFFAABB8D8A6678...

Query by tile coordinates:

select ST_AsPng('roads', 1, 6, 3, '');

Output:

st_aspng
----------
0xFFAABB8D8A6678...