A modular geospatial engine written in JavaScript and TypeScript
Installations
npm install @turf/turf
Developer Guide
Typescript
Yes
Module System
ESM, UMD
Node Version
18.20.4
NPM Version
lerna/8.1.7/node@v18.20.4+x64 (linux)
Score
71.6
Supply Chain
78.9
Quality
87.5
Maintenance
100
Vulnerability
97
License
Releases
Contributors
Languages
TypeScript (86.84%)
JavaScript (13.15%)
Shell (0.01%)
Developer
Download Statistics
Total Downloads
62,778,365
Last Day
41,639
Last Week
663,585
Last Month
3,070,540
Last Year
24,511,684
GitHub Statistics
9,454 Stars
3,691 Commits
944 Forks
182 Watching
46 Branches
165 Contributors
Bundle Size
528.02 kB
Minified
131.46 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
7.1.0
Package Id
@turf/turf@7.1.0
Unpacked Size
585.18 kB
Size
143.88 kB
File Count
10
NPM Version
lerna/8.1.7/node@v18.20.4+x64 (linux)
Node Version
18.20.4
Publised On
09 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
62,778,365
Last day
-74.3%
41,639
Compared to previous day
Last week
-4.3%
663,585
Compared to previous week
Last month
3.6%
3,070,540
Compared to previous month
Last year
58.5%
24,511,684
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
114
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
Turf modules ship with type definitions packaged in each module. No DefinitelyTyped packages required.
The types defined in the GeoJSON specification are maintained separately (Geometry, Polygon, etc). To refer to these in your own code, install @types/geojson
and import from there:
1import { type Polygon } from "geojson";
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
19 commit(s) and 17 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 26/29 approved changesets -- score normalized to 8
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-mwcw-c2x4-8c55
- 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 27 are checked with a SAST tool
Score
6.4
/10
Last Scanned on 2024-12-23
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