A modular geospatial engine written in JavaScript and TypeScript
Installations
npm install @turf/along
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
18.20.4
NPM Version
lerna/8.1.7/node@v18.20.4+x64 (linux)
Statistics
9,394 Stars
3,681 Commits
944 Forks
181 Watching
46 Branches
161 Contributors
Updated on 27 Nov 2024
Languages
TypeScript (86.71%)
JavaScript (13.29%)
Shell (0.01%)
Total Downloads
Cumulative downloads
Total Downloads
79,076,577
Last day
20.6%
203,614
Compared to previous day
Last week
8.9%
967,999
Compared to previous week
Last month
9.2%
3,711,910
Compared to previous month
Last year
41%
28,788,246
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
A modular geospatial engine written in JavaScript
Turf is a JavaScript library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. Turf can be added to your website as a client-side plugin, or you can run Turf server-side with Node.js (see below).
Installation
In Node.js
1# get all of turf 2npm install @turf/turf 3 4# or get individual packages 5npm install @turf/helpers 6npm install @turf/buffer
In browser
Download the minified file, and include it in a script tag. This will expose a global variable named turf
.
1<script src="turf.min.js" charset="utf-8"></script>
You can also include it directly from a CDN:
1<script src="https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js"></script>
TypeScript
TypeScript definitions are packaged with each module. No DefinitelyTyped packages required.
Other languages
Ports of Turf.js are available in:
- Java (Android, Java SE)
- Swift (iOS, macOS, tvOS, watchOS, Linux)
-
Turf for Swift is experimental and its public API is subject to change. Please use with care.
-
- Dart/Flutter (Dart Web, Dart Native; Flutter for iOS, Android, macOS, Windows, Linux, Web)
-
The Turf for Dart port is still in progress, the implementation status can be found in the README.
-
Data in Turf
Turf uses GeoJSON for all geographic data. Turf expects the data to be standard WGS84 longitude, latitude coordinates. Check out geojson.io for a tool to easily create this data.
NOTE: Turf expects data in (longitude, latitude) order per the GeoJSON standard.
Most Turf functions work with GeoJSON features. These are pieces of data that represent a collection of properties (ie: population, elevation, zipcode, etc.) along with a geometry. GeoJSON has several geometry types such as:
- Point
- LineString
- Polygon
Turf provides a few geometry functions of its own. These are nothing more than simple (and optional) wrappers that output plain old GeoJSON. For example, these two methods of creating a point are functionally equivalent:
1// Note order: longitude, latitude. 2var point1 = turf.point([-73.988214, 40.749128]); 3 4var point2 = { 5 type: 'Feature', 6 geometry: { 7 type: 'Point', 8 // Note order: longitude, latitude. 9 coordinates: [-73.988214, 40.749128] 10 }, 11 properties: {} 12};
Browser support
Turf packages are compiled to target ES2017. However, the browser version of @turf/turf is transpiled to also include support for IE11. If you are using these packages and need to target IE11, please transpile the following packages as part of your build:
@turf/*
robust-predicates
rbush
tinyqueue
Contributors
This project exists thanks to all the people who contribute. If you are interested in helping, check out the Contributing Guide.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
No vulnerabilities found.
Reason
12 commit(s) and 19 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
project is fuzzed
Details
- Info: OSSFuzz integration found
Reason
Found 28/29 approved changesets -- score normalized to 9
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/prerelease.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:9
- Info: topLevel 'contents' permission set to 'read': .github/workflows/turf.yml:14
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/prerelease.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/prerelease.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/prerelease.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/turf.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/turf.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/turf.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Score
6.5
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More