Returns a geography value from a Well-Known Text (WKT) or Extended Well-Known Text (EWKT) representation.
Syntax
geography ST_GeogFromText(text eWKT);Parameters
| Parameter | Description |
|---|---|
eWKT | A WKT or EWKT string representing a geographic shape. To specify a spatial reference identifier (SRID), prefix the string with SRID=<value>; (for example, SRID=4326;POINT(116 40)). |
Usage notes
If no SRID is specified, the default SRID 4326 (WGS84) is used.
ST_GeogFromTextis an alias forST_GeographyFromText. Both functions are equivalent.Coordinates are in longitude-latitude order (longitude first, latitude second).
Longitude comes first in the coordinate pair—this is the most common source of errors when working with ST_GeogFromText. Longitude represents the x-axis; latitude represents the y-axis.Examples
Construct a geography object with the default SRID
When no SRID is specified, SRID 4326 is used automatically.
SELECT ST_SRID(ST_GeogFromText('POINT(116 40)'));
st_srid
---------
4326
(1 row)Construct a geography object with a specified SRID
Prefix the WKT string with SRID=<value>; to use a non-default coordinate system.
SELECT ST_SRID(ST_GeogFromText('SRID=4256;POINT(116 40)'));
st_srid
---------
4256
(1 row)See also
ST_GeographyFromText— Alias forST_GeogFromText; both functions are equivalent.ST_SRID— Returns the SRID of ageographyvalue.
该文章对您有帮助吗?