---
title: Linestring Constructors
slug: 4fefglJnMl_P6AShTT3Va
description: Create and manage linestrings in OcientGeo, suitable for spatial data representation and analysis.
docTags: 
createdAt: Mon Aug 01 2022 17:17:59 GMT+0000 (Coordinated Universal Time)
updatedAt: Mon Mar 30 2026 18:52:28 GMT+0000 (Coordinated Universal Time)
---

OcientGeo™ LINESTRING constructors use geospatial data to create a LINESTRING object.

# ST\_LINEFROMTEXT

Alias for ST\_LINESTRING(CHAR).

Creates a `LINESTRING` from a specified `CHAR`. The `CHAR` must be a `LINESTRING` value in WKT format.&#x20;

**Syntax**

```sql
ST_LINEFROMTEXT(char)
```

| **Argument** | **Data** **Type** | **Description**                                                       |
| ------------ | ----------------- | --------------------------------------------------------------------- |
| `char`       | `CHAR`            | A character value in WKT format to be used to create a `LINESTRING`.  |

**Example**

```sql
SELECT ST_LINEFROMTEXT('LINESTRING(1 2)');
```

*Output*: `LINESTRING(1.000000 2.000000)`

# ST\_LINEFROMWKB

Alias for ST\_LINESTRING(BINARY).

Creates a `LINESTRING` from the specified `BINARY`. The `BINARY` value must be a `LINESTRING` in WKB format.&#x20;

**Syntax**

```sql
ST_LINEFROMWKB(binary)
```

| **Argument** | **Data** **Type** | **Description**                                                    |
| ------------ | ----------------- | ------------------------------------------------------------------ |
| `binary`     | `BINARY`          | A binary value in WKB format to be used to create a `LINESTRING`.  |

**Example**

```sql
SELECT ST_LINEFROMWKB(
        BINARY(
'0x010200000002000000000000000000f03f000000000000004000000000000008400000000000001040'
        )
    );
```

*Output*: `LINESTRING(1 2,3 4)`

# ST\_LINEFROMEWKT

Creates a `LINESTRING` from the specified `CHAR`.&#x20;

The `CHAR` value must be a `LINESTRING` in EWKT format.&#x20;

`ST_LINEFROMEWKT` is functionally the same as `ST_LINESTRING(CHAR)`.

The input string must include an `SRID=…​;` value. However, the database ignores this component as all Ocient® geography types are SRID 4326.

**Syntax**

```sql
ST_LINEFROMEWKT('SRID=value;char')
```

| **Argument** | **Data** **Type** | **Description**                                                                                                                                                           |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `char`       | `CHAR`            | A `LINESTRING` value in WKT format to be used to create a `LINESTRING`. <br />To function properly, you must prefix this argument with an SRID value in the same string.  |
| `value`      | `INTEGER`         | Any integer value. This is required, however, the database ignores this component and defaults to SRID 4326.                                                              |

**Example**

```sql
SELECT ST_LINEFROMEWKT('SRID=4326;LINESTRING(1 2)');
```

*Output*: `LINESTRING(1.000000 2.000000)`

# ST\_LINEFROMGEOJSON

Creates a `LINESTRING` represented by the specified GeoJSON. The specified GeoJSON can represent a GeoJSON `POINT` or `LINESTRING` type.&#x20;

Valid GeoJSON formats follow IETF®[ standards](https://datatracker.ietf.org/doc/rfc7946/), and you can generate them by using [ST\_ASGEOJSON](<./Conversion Functions.md>). If you specify an invalid GeoJSON, the behavior of the function is undefined.&#x20;

**Syntax**

```sql
ST_LINEFROMGEOJSON(geojson [, geodesic ])
```

| **Argument** | **Data** **Type** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `geojson`    | `CHAR`            | A GeoJSON value that represents a `POINT` or `LINESTRING` type that is used to create a `LINESTRING`. <br />If `geojson` is NULL, the function returns NULL.                                                                                                                                                                                                                                                            |
| `geodesic`   | `BOOLEAN`         | Optional. A `BOOLEAN` value that determines if the specified `geojson` should be converted from a planar to a geodesic representation.<br />If you specify `geodesic` as `TRUE`, the function adds points to the resulting `LINESTRING` such that it remains within 10 meters of the original planar line.<br />If unspecified, `geodesic` defaults to `FALSE`.<br />If `geodesic` is NULL, the function returns NULL.  |

**Examples**

In this example, the function converts an empty GeoJSON value of a `LINESTRING`.

```sql
SELECT ST_LINEFROMGEOJSON('{"type":"LineString","coordinates":[]}',false);
```

*Output*:  `LINESTRING EMPTY`&#x20;

In this example, the function converts a GeoJSON value of a `LINESTRING`.

```sql
SELECT ST_LINEFROMGEOJSON(
        '{"type":"LineString","coordinates":[[1,1],[1,5],[5,5],[5,1]]}',
        false);
```

*Output*:  `LINESTRING(1 1, 1 5, 5 5, 5 1)`

# ST\_LINESTRING

Alias for ST\_MAKELINE.&#x20;

Creates a `LINESTRING` based on the specified inputs.&#x20;

## ST\_LINESTRING(geoArray)

Creates a `LINESTRING` from the specified array of either `LINESTRING` or `POINT` values.

**Syntax**

```sql
ST_LINESTRING(geo_array)
```

| **Argument** | **Data** **Type**                                              | **Description**                                                                         |
| ------------ | -------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `geo_array`  | `ARRAY` of geographies, either `LINESTRING` or `POINT` values. | An array of `LINESTRING` or `POINT` values to be used to create a unified `LINESTRING`. |

**Example**

```sql
SELECT ST_LINESTRING(
        ST_LINESTRING [](ST_LINESTRING(ST_POINT(1, 2), ST_POINT(3, 4))));
```

*Output*: `LINESTRING(1.000000 2.000000, 3.000000 4.000000)`

## ST\_LINESTRING(binary)

Creates a `LINESTRING` from the specified `BINARY`. The `BINARY` value must be a `LINESTRING` in WKB format.

**Syntax**

```sql
ST_LINESTRING(binary)
```

| **Argument** | **Data** **Type** | **Description**                                                                                                |
| ------------ | ----------------- | -------------------------------------------------------------------------------------------------------------- |
| `binary`     | `BINARY`          | A `BINARY` value to be used to create a `LINESTRING`. The `BINARY` value must be a `LINESTRING` in WKB format. |

**Example**

```sql
SELECT ST_LINESTRING(BINARY('0x010200000002000000000000000000f03f000000000000004000000000000008400000000000001040'));
```

*Output*: `LINESTRING(1 2,3 4)`

## ST\_LINESTRING(char)

Creates a `LINESTRING` from the specified `CHAR`. The `CHAR` value must be a `LINESTRING` in WKT format.

**Syntax**

```sql
ST_LINESTRING(char)
```

| **Argument** | **Data** **Type** | **Description**                                                                                        |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------ |
| `char`       | `CHAR`            | A `CHAR` value to be used to create a `LINESTRING`. The argument must be a `LINESTRING` in WKT format. |

**Example**

```sql
SELECT ST_LINESTRING('LINESTRING(1 2)');
```

*Output*: `LINESTRING(1.000000 2.000000)`

## ST\_LINESTRING(geo1, geo2)

Creates a `LINESTRING` consisting of two separate geographic arguments, both of which must be either a `POINT` or `LINESTRING`. You can mix geographic types, meaning one argument can be a `POINT` while the other is a `LINESTRING`.

**Syntax**

```sql
ST_LINESTRING(geo1, geo2)
```

| **Argument**   | **Data** **Type**       | **Description**                                                                                                                          |
| -------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `geo1`, `geo2` | `POINT` or `LINESTRING` | Two separate geographic arguments to be consolidated into a single `LINESTRING`. <br /><br />Inputs can be the same type or one of each. |

**Example**

```sql
SELECT ST_LINESTRING(ST_POINT(1, 2), ST_POINT(1,3));
```

*Output*: `LINESTRING(1.000000 2.000000, 1.000000 3.000000)`

# ST\_MAKELINE

Alias for [ST\_LINESTRING](./#stlinestring).

## ST\_MAKELINE(geo1, geo2)

Alias for [ST\_LINESTRING(geo1, geo2)](./#stlinestringgeo1-geo2).

## ST\_MAKELINE(CHAR)

Alias for [ST\_LINESTRING(char)](./#stlinestringchar).

## ST\_MAKELINE(geoArray)

Alias for [ST\_LINESTRING(geoArray)](./#stlinestringgeoarray).

# Related Links

[Geospatial Data Types](<././Data Types.md>)

[Linestring Functions](<./Linestring Functions.md>)

[Conversion Functions](<./Conversion Functions.md>)

