ST_GeomFromText

更新时间:
复制 MD 格式

Constructs a geometry object from a Well-Known Text (WKT) string.

Syntax

geometry ST_GeomFromText(text WKT);
geometry ST_GeomFromText(text WKT, integer srid);

Parameters

ParameterDescription
WKTThe WKT string representing the geometry.
sridThe spatial reference identifier (SRID) to assign to the geometry object.

Description

This function supports circular strings and curves.

Examples

Construct a geometry object without an SRID

SELECT ST_GeomFromText('POINT(116 40)');

Output:

          st_geomfromtext
--------------------------------------------
 01010000000000000000005D400000000000004440
(1 row)

Construct a geometry object with a specified SRID

SELECT ST_GeomFromText('POINT(116 40)', 4326);

Output:

                  st_geomfromtext
----------------------------------------------------
 0101000020E61000000000000000005D400000000000004440
(1 row)