Geometry.ToWellKnownText

Value

Translates a structured geometric point value into its Well-Known Text (WKT) representation.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Geometry.ToWellKnownText(input as nullable record, optional omitSRID as nullable logical) as nullable text

Parameters

NameTypeRequiredDescription
inputrecordYesA structured record representing a geometric value to convert to WKT format.
omitSRIDlogicalNoWhen true, omits the SRID (Spatial Reference Identifier) prefix from the output. Defaults to false.

Return Value

textA text value containing the WKT representation of the geometric value, or null if the input is null.

Remarks

Geometry.ToWellKnownText converts a structured geometric 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=0;POINT(10 20)"). When omitSRID is set to true, only the WKT portion is returned (e.g., "POINT(10 20)").

This function is the inverse of Geometry.FromWellKnownText. It is useful for serializing geometric values back to text for storage in databases or for interoperability with systems that consume WKT.

Geometry types use a flat Cartesian (planar) coordinate system. For round-earth geographic data (latitude/longitude), use Geography.ToWellKnownText instead.

If the input is null, the function returns null.

Examples

Example 1: Convert a geometric point record to WKT

let
    Point = GeometryPoint.From(10, 20),
    WKT = Geometry.ToWellKnownText(Point)
in
    #table({"WKT"}, {{WKT}})

Example 2: Convert to WKT without SRID prefix

let
    Point = GeometryPoint.From(100, 200),
    WKTWithSRID = Geometry.ToWellKnownText(Point),
    WKTWithoutSRID = Geometry.ToWellKnownText(Point, true)
in
    #table({"With SRID", "Without SRID"}, {{WKTWithSRID, WKTWithoutSRID}})

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks