Geometry.FromWellKnownText

Value

Translates text representing a geometric value in Well-Known Text (WKT) format into a structured record.

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

Syntax

Geometry.FromWellKnownText(input as nullable text) as nullable record

Parameters

NameTypeRequiredDescription
inputtextYesA text value containing a geometric value in Well-Known Text (WKT) format.

Return Value

recordA structured record representing the geometric value parsed from the WKT string, or null if the input is null.

Remarks

Geometry.FromWellKnownText parses a Well-Known Text (WKT) string and returns a structured record representing a geometric value. WKT is a standard text format defined by the Open Geospatial Consortium (OGC) for representing spatial reference system objects. It is the typical serialization format used by databases including SQL Server.

Geometric values use a flat Cartesian (planar) coordinate system, as opposed to geographic values which use a round-earth model based on latitude and longitude. The default spatial reference identifier (SRID) for geometry types is 0.

Common WKT geometry types include POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEOMETRYCOLLECTION. For example, a point at coordinates (10, 20) would be represented as "POINT(10 20)".

Use Geometry.FromWellKnownText when working with planar coordinate data such as floor plans, engineering drawings, or projected map coordinates. For GPS-style latitude/longitude data, use Geography.FromWellKnownText instead.

If the input is null, the function returns null.

Examples

Example 1: Parse a WKT point into a record

let
    WKT = "POINT(10 20)",
    Result = Geometry.FromWellKnownText(WKT)
in
    Record.ToTable(Result)

Example 2: Parse a WKT polygon

let
    WKT = "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))",
    Result = Geometry.FromWellKnownText(WKT)
in
    Record.ToTable(Result)

Example 3: Parse WKT geometry values from a table column

let
    Source = #table({"Shape", "WKT"}, {
        {"Origin", "POINT(0 0)"},
        {"Square", "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))"}
    }),
    Parsed = Table.AddColumn(Source, "Geometry", each Geometry.FromWellKnownText([WKT]))
in
    Parsed

Compatibility

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