
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@turf/line-offset
Advanced tools
@turf/line-offset is a module in the Turf.js library that allows you to create parallel lines at a specified distance from the input line. This can be useful for various geospatial operations such as creating buffer zones, road networks, or any application where you need to generate offset lines from a given line geometry.
Create an offset line
This feature allows you to create a line that is offset by a specified distance from the original line. In this example, the line is offset by 2 miles.
const turf = require('@turf/turf');
const line = turf.lineString([[0, 0], [10, 10]]);
const offsetLine = turf.lineOffset(line, 2, { units: 'miles' });
console.log(JSON.stringify(offsetLine));
JSTS (JavaScript Topology Suite) is a JavaScript library of spatial predicates and functions for processing geometry. It provides similar functionality to @turf/line-offset, such as creating buffer zones and offset lines, but it is more comprehensive and includes a wider range of geometric operations.
Geolib is a library to provide basic geospatial operations like distance calculation, bounding boxes, and more. While it does not specifically focus on line offsetting, it offers a variety of geospatial utilities that can complement the functionalities provided by @turf/line-offset.
Takes a line and returns a line at offset by the specified distance.
geojson
(Geometry | Feature<(LineString | MultiLineString)>) input GeoJSON
distance
number distance to offset the line (can be of negative value)
options
Object Optional parameters (optional, default {}
)
options.units
string can be degrees, radians, miles, kilometers, inches, yards, meters (optional, default 'kilometers'
)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.
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
FAQs
turf line-offset module
The npm package @turf/line-offset receives a total of 752,027 weekly downloads. As such, @turf/line-offset popularity was classified as popular.
We found that @turf/line-offset demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.