ST_GeomFromKML

更新时间:
复制 MD 格式

Constructs a geometry object from a Keyhole Markup Language (KML) string.

Syntax

geometry ST_GeomFromKML(text geomkml);

Parameters

ParameterTypeDescription
geomkmltextThe KML geometry fragment to convert.

Usage notes

  • KML geometry fragments only. Pass a KML geometry fragment, not a full KML document. Passing a full KML document returns an error.

  • 3D support. The function preserves 3D objects and retains the z-coordinate of the constructed geometry object.

Examples

Convert a KML Point element to a geometry object and return its well-known text (WKT) representation:

SELECT ST_AsText(ST_GeomFromKML('<Point><coordinates>116,40</coordinates></Point>'));
   st_astext
---------------
 POINT(116 40)
(1 row)