Share via


st_makeline function

Applies to: check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Returns a linestring GEOMETRY whose points are the non-empty points of the geometries in the input array of geometries, which are expected to be points, linestrings, or multipoints.

Syntax

st_makeline ( geoArray )

Arguments

  • geoArray: An array of GEOMETRY values.

Returns

A value of type GEOMETRY, representing a linestring.

The order of the points is preserved in the output linestring. Any NULL values in the input array are ignored.

The SRID value of the output linestring is the common SRID value of the input geometries.

The dimension of the output linestring is the maximum common dimension of the input geometries.

If the input array is empty, the 2D empty linestring is returned. The SRID of the returned linestring is 0 in this case. If all input geometries are empty, the 2D empty linestring is returned. If the total number of non-empty points across all input geometries is one, we return a linestring with two points, both of which are equal to the unique non-empty point in the input.

The function returns NULL if any of the inputs is NULL.

Error conditions

Examples

-- Returns a linestring with the points of the input geometries.
> SELECT st_astext(st_makeline(array(st_geomfromtext('POINT(1 2)'),st_geomfromtext('MULTIPOINT(5 6,7 8)'),st_geomfromtext('LINESTRING(5 6,7 8,-1 -3,-7 -9,-12 -20)'))))
  LINESTRING(1 2,5 6,7 8,5 6,7 8,-1 -3,-7 -9,-12 -20)