All Products
Search
Document Center

MaxCompute:ST_MAKELINE

Last Updated:Aug 26, 2026

The ST_MAKELINE function creates a LINESTRING geography object from specified endpoints.

Syntax

The ST_MAKELINE function has two signatures. Select the one that matches your use case.

  • Signature 1: Creates a LINESTRING geography object from two endpoints.

    GEOGRAPHY ST_MAKELINE(GEOGRAPHY <point1>, GEOGRAPHY <point2>)
  • Signature 2: Creates a LINESTRING geography object from an ARRAY of one or more endpoints.

    GEOGRAPHY ST_MAKELINE(ARRAY<GEOGRAPHY> <points>)

Parameters

Return value

Returns a LINESTRING geography object. The following rules apply:

  • Returns NULL if any input GEOGRAPHY parameter is NULL, or if the input ARRAY or any of its elements is NULL.

  • If the input consists of two identical points or an ARRAY with a single point, the result degenerates into a POINT geography object.

  • The precision limitations of the S2 Geography Library may cause minor discrepancies between the input and output.

Examples

  • Example 1: Create a LINESTRING geography object from two endpoints.

    -- Provide two different endpoints to create a LINESTRING.
    SELECT ST_MAKELINE(ST_GEOGPOINT(270, 0), ST_GEOGPOINT(1, 1));
    -- Result:
    +-------------------------+
    | _c0                     |
    +-------------------------+
    | LINESTRING (-90 0, 1 1) |
    +-------------------------+
    
    -- Provide two identical endpoints. The result degenerates to a POINT.
    SELECT ST_MAKELINE(ST_GEOGPOINT(1, 1), ST_GEOGPOINT(1, 1));
    -- Result:
    +-------------+
    | _c0         |
    +-------------+
    | POINT (1 1) |
    +-------------+
  • Example 2: Create a LINESTRING geography object from an ARRAY of one or more endpoints.

    -- Provide an ARRAY of points to create a LINESTRING.
    SELECT ST_MAKELINE(ARRAY(ST_GEOGPOINT(0, 0), ST_GEOGPOINT(1, 1), ST_GEOGPOINT(2, 2)));
    -- Result:
    +----------------------------+
    | _c0                        |
    +----------------------------+
    | LINESTRING (0 0, 1 1, 2 2) |
    +----------------------------+
    
    -- Provide an ARRAY with a single element. The result degenerates to a POINT.
    SELECT ST_MAKELINE(ARRAY(ST_GEOGPOINT(0, 0)));
    -- Result:
    +-------------+
    | _c0         |
    +-------------+
    | POINT (0 0) |
    +-------------+

Related topics