Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/length

Package Overview
Dependencies
Maintainers
9
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/length

turf length module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
900K
increased by2.03%
Maintainers
9
Weekly downloads
 
Created

What is @turf/length?

@turf/length is a module from the Turf.js library that allows you to calculate the length of a GeoJSON LineString or MultiLineString. It is useful for geographic data analysis and manipulation, particularly when working with spatial data in web applications.

What are @turf/length's main functionalities?

Calculate Length of LineString

This feature allows you to calculate the length of a LineString in the specified units (e.g., miles, kilometers). The code sample demonstrates how to create a LineString and calculate its length in miles.

const turf = require('@turf/length');
const line = {
  "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [-77.031669, 38.878605],
      [-77.029609, 38.881946],
      [-77.020339, 38.884084],
      [-77.025661, 38.885821]
    ]
  }
};
const length = turf(line, {units: 'miles'});
console.log(length);

Calculate Length of MultiLineString

This feature allows you to calculate the length of a MultiLineString in the specified units (e.g., kilometers). The code sample demonstrates how to create a MultiLineString and calculate its length in kilometers.

const turf = require('@turf/length');
const multiLine = {
  "type": "Feature",
  "geometry": {
    "type": "MultiLineString",
    "coordinates": [
      [
        [-77.031669, 38.878605],
        [-77.029609, 38.881946]
      ],
      [
        [-77.020339, 38.884084],
        [-77.025661, 38.885821]
      ]
    ]
  }
};
const length = turf(multiLine, {units: 'kilometers'});
console.log(length);

Other packages similar to @turf/length

Keywords

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc