Geography.ToWellKnownText
ValueTranslates a structured geographic point value into its Well-Known Text (WKT) representation.
Syntax
Geography.ToWellKnownText(input as nullable record, optional omitSRID as nullable logical) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
input | record | Yes | A structured record representing a geographic value to convert to WKT format. |
omitSRID | logical | No | When true, omits the SRID (Spatial Reference Identifier) prefix from the output. Defaults to false. |
Return Value
text — A text value containing the WKT representation of the geographic value, or null if the input is null.
Remarks
Geography.ToWellKnownText converts a structured geographic record into its Well-Known Text (WKT) string representation as defined by the Open Geospatial Consortium (OGC). WKT is the standard serialization format used by many databases including SQL Server.
The optional omitSRID parameter controls whether the Spatial Reference Identifier (SRID) prefix is included in the output. By default, the SRID is included (e.g., "SRID=4326;POINT(-122.3321 47.6062)"). When omitSRID is set to true, only the WKT portion is returned (e.g., "POINT(-122.3321 47.6062)").
This function is the inverse of Geography.FromWellKnownText. It is useful for serializing geographic values back to text for storage in databases or for interoperability with systems that consume WKT.
If the input is null, the function returns null.
Examples
Example 1: Convert a geographic point record to WKT
let
Point = GeographyPoint.From(-122.3321, 47.6062),
WKT = Geography.ToWellKnownText(Point)
in
#table({"WKT"}, {{WKT}})Example 2: Convert to WKT without SRID prefix
let
Point = GeographyPoint.From(-74.006, 40.7128),
WKTWithSRID = Geography.ToWellKnownText(Point),
WKTWithoutSRID = Geography.ToWellKnownText(Point, true)
in
#table({"With SRID", "Without SRID"}, {{WKTWithSRID, WKTWithoutSRID}})