> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LINESTRING

A `LINESTRING` is a collection of [Points](/docs/stable/point.md) that are "strung together" into one geometric object. A LineString can be used to represent an arbitrary curve, such as a [Bézier curve](https://wikipedia.org/wiki/Bézier_curve).  In practice, this means that LineStrings are useful for representing real-world objects such as roads and rivers.

The coordinates of each Point that makes up the LineString are translated according to the current [spatial reference system](/docs/stable/architecture/glossary.md#spatial-reference-system) (denoted by an [SRID](/docs/stable/architecture/glossary.md#srid)) to determine what the Point "is", or what it "means" relative to the [other spatial objects](/docs/stable/spatial-data-overview.md#spatial-objects) (if any) in the data set.

You can also store a \`\` with the following additional dimensions:

* A third dimension coordinate `Z` (`Z`).
* A measure coordinate `M` (`M`).
* Both a third dimension and a measure coordinate (`ZM`).

The `Z` and `M` dimensions can be accessed or modified using a number of [built-in functions](/docs/stable/functions-and-operators.md#spatial-functions), including:

* `ST_Z`
* `ST_M`
* `ST_Affine`
* `ST_Zmflag`
* `ST_MakePoint`
* `ST_MakePointM`
* `ST_Force3D`
* `ST_Force3DZ`
* `ST_Force3DM`
* `ST_Force4D`
* `ST_Snap`
* `ST_SnapToGrid`
* `ST_RotateZ`
* `ST_AddMeasure`

Note that CockroachDB's [spatial indexing](/docs/stable/spatial-indexes.md) is still based on the 2D coordinate system.  This means that:

* The Z/M dimension is not index accelerated when using spatial predicates.
* Some spatial functions ignore the Z/M dimension, with transformations discarding the Z/M value.

## Examples

A LineString can be created from SQL by calling the `st_geomfromtext` function on a LineString definition expressed in the [Well Known Text (WKT)](/docs/stable/architecture/glossary.md#wkt) format as shown below.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT ST_GeomFromText('LINESTRING(0 0, 1440 900)');
```

```
                                   st_geomfromtext
--------------------------------------------------------------------------------------
  0102000000020000000000000000000000000000000000000000000000008096400000000000208C40
(1 row)
```

You can also make a LineString using the [aggregate function form](/docs/stable/functions-and-operators.md#aggregate-functions) of `st_makeline`.

## See also

* [Spatial objects](/docs/stable/spatial-data-overview.md#spatial-objects)
* [POINT](/docs/stable/point.md)
* [POLYGON](/docs/stable/polygon.md)
* [MULTIPOINT](/docs/stable/multipoint.md)
* [MULTILINESTRING](/docs/stable/multilinestring.md)
* [MULTIPOLYGON](/docs/stable/multipolygon.md)
* [GEOMETRYCOLLECTION](/docs/stable/geometrycollection.md)
