Skip to main content
Version: Next

lineString

Description

Creates a LineString Feature from an Array of Positions.

Parameters

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

Returns

Feature<LineString, GeoJsonProperties> LineString Feature

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(...);