This topic describes the ST_PointFromText function. This function constructs a point object by using a Well-Known Text (WKT) string and a spatial reference identifier (SRID).
Syntax
geometry ST_PointFromText(text wKT);
geometry ST_PointFromText(text wKT , integer srid);Parameters
| Parameter | Description |
|---|---|
| wKT | The WKT string that you want to specify. |
| srid | The SRID of the point object. |
Description
- If you do not specify an SRID, the default SRID 0 is used.
- If the WKT string that you specify does not represent a point, this function returns NULL.
- If the WKT string that you specify is invalid, this function returns an error.
- If you can make sure that the information that you specify can be used to construct a point object, we recommend that you use the ST_GeomFromText function, which constructs a geometry object at a higher speed because no unnecessary checks are required.
- If you want to construct a point object by using latitude and longitude coordinates and you are concerned more about performance and accuracy than about compatibility with the Open Geospatial Consortium (OGC) specification, we recommend that you use the ST_MakePoint function or the ST_Point function.
Examples
Construct a point object by using a specified SRID.
SELECT ST_AsEWKT(ST_PointFromText('POINT(119 40)', 4326));
st_asewkt
-------------------------
SRID=4326;POINT(119 40)
(1 row)