This topic describes the ST_MakeLine function. This function constructs a LineString object by using geometry objects, such as points, MultiPoints, or lines.
Syntax
geometry ST_MakeLine(geometry set geoms);
geometry ST_MakeLine(geometry geom1 , geometry geom2);
geometry ST_MakeLine(geometry[] geomsArray);Parameters
| Parameter | Description |
|---|---|
| geoms | The geometry objects that you want to specify. |
| geom1 | The first geometry object that you want to specify. |
| geom2 | The second geometry object that you want to specify. |
| geomsArray | An array that consists of the geometry objects you want to specify. |
Description
- If you specify geometry objects that are not points, MultiPoints, or lines, this function ignores the specified geometry objects.
- When a LineString object is added, this function deletes the common nodes at the beginning of lines. If you specify points or MultiPoints, this function does not delete the common nodes at the beginning of points or MultiPoints.
- This function supports 3D objects and does not discard the z-index of the geometry object that is constructed.
Examples
- Construct a LineString object by using the default parameter settings.
SELECT ST_AsText(ST_MakeLine(ST_MakePoint(1,2), ST_MakePoint(3,4))); st_astext --------------------- LINESTRING(1 2,3 4) (1 row) - Construct a 3D LineString object.
SELECT ST_AsText(ST_MakeLine(ST_MakePoint(1,2,3), ST_MakePoint(4,5,6))); st_astext ---------------------------- LINESTRING Z (1 2 3,4 5 6) (1 row) - Construct a LineString object by using an array.
SELECT ST_AsText(ST_MakeLine(ARRAY[ST_MakePoint(1,2),ST_MakePoint(3,4), ST_MakePoint(5,6)])); st_astext ------------------------- LINESTRING(1 2,3 4,5 6) (1 row)