Returns the Keyhole Markup Language (KML) representation of a geometry or geography object.
Syntax
text ST_AsKML(geometry geom, integer maxdecimaldigits=15);
text ST_AsKML(geography geog, integer maxdecimaldigits=15);
text ST_AsKML(integer version, geometry geom, integer maxdecimaldigits=15, text nprefix=NULL);
text ST_AsKML(integer version, geography geog, integer maxdecimaldigits=15, text nprefix=NULL);Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
geom | geometry | — | The geometry object to convert to KML. |
geog | geography | — | The geography object to convert to KML. |
maxdecimaldigits | integer | 15 | The maximum number of decimal places in the output coordinates. |
version | integer | 2 | The KML version. 2 uses GML version 2.1.2; 3 uses GML version 3.1.1. |
nprefix | text | NULL | The namespace prefix. Pass a custom string to add a prefix to KML elements. |
Usage notes
Supports 3D objects and preserves the z-index of each point.
Examples
2D polygon
SELECT ST_AsKML(ST_GeomFromText('POLYGON((1 1,1 2,2 2,2 1,1 1))', 4326));Output:
<Polygon><outerBoundaryIs>
<LinearRing><coordinates>1,1 1,2 2,2 2,1 1,1</coordinates>
</LinearRing></outerBoundaryIs>
</Polygon>See also
该文章对您有帮助吗?