Skip to main content
Version: 7.0.0

lineString

Description

Creates a LineString Feature from an Array of Positions.

Parameters

NameTypeDescription
coordinatesArray<Array<number>>an array of Positions
properties?Objectan Object of key-value pairs to add as properties (default {})
options?ObjectOptional Parameters (default {})
options.bbox?Array<number>Bounding Box Array [west, south, east, north] associated with the Feature
options.id?string | numberIdentifier associated with the Feature

Returns

Examples

var linestring1 = turf.lineString(
[
[-24, 63],
[-23, 60],
[-25, 65],
[-20, 69],
],
{ name: "line 1" },
);
var linestring2 = turf.lineString(
[
[-14, 43],
[-13, 40],
[-15, 45],
[-10, 49],
],
{ name: "line 2" },
);

//=linestring1
//=linestring2

Installation

$ npm install @turf/helpers

import { lineString } from "@turf/helpers";
const result = lineString(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.lineString(...);