Model / geo · All operations

Build geometry from coordinates

A variant of Work with geography

Make a point, line or polygon column from X and Y values or from text or binary geometry.

Status

In arcform

Runs as a SQL step

arcform carries it as a sql: step today, with the spatial extension.

The DuckDB step

Make points, lines and polygons from coordinates, text and binary

SQL
INSTALL spatial; LOAD spatial; SET geometry_always_xy = true;

CREATE TEMP TABLE coords AS SELECT * FROM (VALUES (1, 1, 0.0, 0.0), (1, 2, 4.0, 0.0), (1, 3, 4.0, 3.0), (2, 1, 10.0, 10.0), (2, 2, 11.0, 12.0)) t(feature, seq, x, y);
-- a point for each coordinate pair
CREATE TEMP TABLE points AS SELECT feature, seq, ST_Point(x, y) AS geom FROM coords;
-- a line through each feature's points in order, and a polygon from the ring of feature 1 closed back to its first point
CREATE TEMP TABLE lines AS SELECT feature, ST_MakeLine(list(geom ORDER BY seq)) AS geom FROM points GROUP BY feature;
CREATE TEMP TABLE polygons AS SELECT ST_MakePolygon(ST_MakeLine(list(geom ORDER BY seq) || [first(geom ORDER BY seq)])) AS geom FROM points WHERE feature = 1;
-- from text, and from binary: well-known text, well-known binary as hex, and a round trip through binary
CREATE TEMP TABLE parsed AS SELECT ST_GeomFromText('POINT (1 2)') AS from_text, ST_GeomFromHEXWKB('0101000000000000000000F03F0000000000000040') AS from_hex, ST_GeomFromWKB(ST_AsWKB(ST_GeomFromText('LINESTRING (0 0, 1 1)'))) AS round_trip;
SELECT feature, ST_AsText(geom) AS line FROM lines ORDER BY feature;
SELECT ST_AsText(geom) AS polygon FROM polygons;
SELECT ST_AsText(from_text), ST_AsText(from_hex), ST_AsText(round_trip) FROM parsed;
SELECT CASE WHEN ((SELECT count(*) = 5 FROM points) AND (SELECT ST_AsText(geom) = 'POINT (4 3)' FROM points WHERE feature = 1 AND seq = 3)
  AND (SELECT list(ST_AsText(geom) ORDER BY feature) = ['LINESTRING (0 0, 4 0, 4 3)', 'LINESTRING (10 10, 11 12)'] FROM lines)
  AND (SELECT ST_AsText(geom) = 'POLYGON ((0 0, 4 0, 4 3, 0 0))' AND ST_Area(geom) = 6 FROM polygons)
  AND (SELECT ST_AsText(from_text) = 'POINT (1 2)' AND ST_Equals(from_text, from_hex) AND ST_GeometryType(round_trip) = 'LINESTRING' AND ST_AsText(round_trip) = 'LINESTRING (0 0, 1 1)' FROM parsed)) THEN 'as expected' ELSE error('the coordinates should become 5 points, the lines (0 0, 4 0, 4 3) and (10 10, 11 12), a triangle of area 6, and the same point from text and from hex binary') END AS verdict;
  • The statement builds its own data.
  • It needs the spatial extension.
  • The statement checks its own result and raises an error when it is wrong: “the coordinates should become 5 points, the lines (0 0, 4 0, 4 3) and (10 10, 11 12), a triangle of area 6, and the same point from text and from hex binary”.
  • It passed on DuckDB v2.0.0 (Cyanoptera) d54cbbe3df.

What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

Alteryx Designer (2)
  • Create Pointsread 2026-09-27

    Create point spatial objects from X and Y coordinate fields

  • Poly-Buildread 2026-09-27

    Draw a polygon or polyline through a group of points in a given order

Duckle (1)
Ibis (1)
  • GeoPointread 2026-09-27

    Build a point from X and Y values

Background

In Alteryx Designer, the Create Points tool makes a point spatial object from input fields holding the X coordinate (longitude) and Y coordinate (latitude).[1] Well-known text (WKT) is a text markup language for representing vector geometry objects.[2] Well-known binary (WKB) carries the same information as WKT in a more compact form that suits computer processing but is not human-readable.[2]

When to use it

In PostGIS's ST_MakePoint, X is longitude and Y is latitude for geodetic coordinates.[3]

The Open Geospatial Consortium (OGC) standard definition requires a WKT polygon to be topologically closed.[2]

The method

WKT and WKB were originally defined by the OGC and described in its Simple Feature Access, and the current standard definition is in ISO/IEC 13249-3:2016.[2] Coordinates in WKT may be 2D (x, y), 3D (x, y, z), 4D (x, y, z, m), or 2D with an m value, where the m value is part of a linear referencing system.[2] In WKT, an empty geometry that contains no coordinates is written with the symbol EMPTY after the type name.[2] The first byte of a WKB value gives the byte order of the data: 0x00 for big endian and 0x01 for little endian.[2]

In DuckDB, geometries can be cast to and from WKT strings, so a string literal can create a geometry directly in a SQL statement.[4] In DuckDB, the vertex dimensions of a GEOMETRY value must be consistent across all its vertices, so one geometry cannot mix 2D and 3D vertices.[4] In DuckDB's spatial extension, ST_MakeLine creates a LINESTRING from a list of POINT geometries, and ST_MakePolygon creates a POLYGON from a LINESTRING shell.[5]

Compared with the alternatives

In PostGIS, ST_MakePoint is not OGC-compliant, but is faster than ST_GeomFromText and ST_PointFromText and easier to use for numeric coordinate values.[3]