mirror of
https://github.com/Turfjs/turf.git
synced 2026-01-25 16:07:00 +00:00
@turf/line-offset
lineOffset
Takes a line and returns a line at offset by the specified distance.
Parameters
-
geojson(Geometry | Feature<(LineString | MultiLineString)>) input GeoJSON -
distancenumber distance to offset the line (can be of negative value) -
optionsObject Optional parameters (optional, default{})options.unitsUnits Supports all valid Turf Units. (optional, default'kilometers')
Examples
var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" });
var offsetLine = turf.lineOffset(line, 2, {units: 'miles'});
//addToMap
var addToMap = [offsetLine, line]
offsetLine.properties.stroke = "#00F"
Returns Feature<(LineString | MultiLineString)> Line offset from the input line
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Installation
Install this single module individually:
$ npm install @turf/line-offset
Or install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf