Installations
npm install milaferichs-turf-helpers
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
8.9.4
NPM Version
5.6.0
Score
74.8
Supply Chain
99.4
Quality
75
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (86.87%)
JavaScript (13.12%)
Shell (0.01%)
Developer
Download Statistics
Total Downloads
569
Last Day
1
Last Week
2
Last Month
10
Last Year
53
GitHub Statistics
9,521 Stars
3,736 Commits
953 Forks
182 Watching
48 Branches
168 Contributors
Bundle Size
8.17 kB
Minified
2.00 kB
Minified + Gzipped
Package Meta Information
Latest Version
6.0.1
Package Id
milaferichs-turf-helpers@6.0.1
Unpacked Size
97.29 kB
Size
11.52 kB
File Count
7
NPM Version
5.6.0
Node Version
8.9.4
Total Downloads
Cumulative downloads
Total Downloads
569
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
233.3%
10
Compared to previous month
Last year
-28.4%
53
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@turf/helpers
earthRadius
Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
factors
Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
unitsFactors
Units of measurement factors based on 1 meter.
areaFactors
Area of measurement factors based on 1 square meter.
feature
Wraps a GeoJSON Geometry in a GeoJSON Feature.
Parameters
geometry
Geometry input geometryproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var geometry = { 2 "type": "Point", 3 "coordinates": [110, 50] 4}; 5 6var feature = turf.feature(geometry); 7 8//=feature
Returns Feature a GeoJSON Feature
geometry
Creates a GeoJSON Geometry from a Geometry string type & coordinates.
For GeometryCollection type use helpers.geometryCollection
Parameters
type
string Geometry Typecoordinates
Array<number> Coordinatesoptions
Object Optional Parameters (optional, default{}
)
Examples
1var type = 'Point'; 2var coordinates = [110, 50]; 3 4var geometry = turf.geometry(type, coordinates); 5 6//=geometry
Returns Geometry a GeoJSON Geometry
point
Creates a Point Feature from a Position.
Parameters
coordinates
Array<number> longitude, latitude position (each in decimal degrees)properties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var point = turf.point([-75.343, 39.984]); 2 3//=point
Returns Feature<Point> a Point feature
points
Creates a Point FeatureCollection from an Array of Point coordinates.
Parameters
coordinates
Array<Array<number>> an array of Pointsproperties
Object Translate these properties to each Feature (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var points = turf.points([ 2 [-75, 39], 3 [-80, 45], 4 [-78, 50] 5]); 6 7//=points
Returns FeatureCollection<Point> Point Feature
polygon
Creates a Polygon Feature from an Array of LinearRings.
Parameters
coordinates
Array<Array<Array<number>>> an array of LinearRingsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' }); 2 3//=polygon
Returns Feature<Polygon> Polygon Feature
polygons
Creates a Polygon FeatureCollection from an Array of Polygon coordinates.
Parameters
coordinates
Array<Array<Array<Array<number>>>> an array of Polygon coordinatesproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var polygons = turf.polygons([ 2 [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], 3 [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]], 4]); 5 6//=polygons
Returns FeatureCollection<Polygon> Polygon FeatureCollection
lineString
Creates a LineString Feature from an Array of Positions.
Parameters
coordinates
Array<Array<number>> an array of Positionsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'}); 2var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'}); 3 4//=linestring1 5//=linestring2
Returns Feature<LineString> LineString Feature
lineStrings
Creates a LineString FeatureCollection from an Array of LineString coordinates.
Parameters
coordinates
Array<Array<number>> an array of LinearRingsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var linestrings = turf.lineStrings([ 2 [[-24, 63], [-23, 60], [-25, 65], [-20, 69]], 3 [[-14, 43], [-13, 40], [-15, 45], [-10, 49]] 4]); 5 6//=linestrings
Returns FeatureCollection<LineString> LineString FeatureCollection
featureCollection
Takes one or more Features and creates a FeatureCollection.
Parameters
Examples
1var locationA = turf.point([-75.343, 39.984], {name: 'Location A'}); 2var locationB = turf.point([-75.833, 39.284], {name: 'Location B'}); 3var locationC = turf.point([-75.534, 39.123], {name: 'Location C'}); 4 5var collection = turf.featureCollection([ 6 locationA, 7 locationB, 8 locationC 9]); 10 11//=collection
Returns FeatureCollection FeatureCollection of Features
multiLineString
Creates a Feature<MultiLineString> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<Array<number>>> an array of LineStringsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var multiLine = turf.multiLineString([[[0,0],[10,10]]]); 2 3//=multiLine
- Throws Error if no coordinates are passed
Returns Feature<MultiLineString> a MultiLineString feature
multiPoint
Creates a Feature<MultiPoint> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<number>> an array of Positionsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var multiPt = turf.multiPoint([[0,0],[10,10]]); 2 3//=multiPt
- Throws Error if no coordinates are passed
Returns Feature<MultiPoint> a MultiPoint feature
multiPolygon
Creates a Feature<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<Array<Array<number>>>> an array of Polygonsproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]); 2 3//=multiPoly
- Throws Error if no coordinates are passed
Returns Feature<MultiPolygon> a multipolygon feature
geometryCollection
Creates a Feature<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Parameters
geometries
Array<Geometry> an array of GeoJSON Geometriesproperties
Object an Object of key-value pairs to add as properties (optional, default{}
)options
Object Optional Parameters (optional, default{}
)
Examples
1var pt = { 2 "type": "Point", 3 "coordinates": [100, 0] 4 }; 5var line = { 6 "type": "LineString", 7 "coordinates": [ [101, 0], [102, 1] ] 8 }; 9var collection = turf.geometryCollection([pt, line]); 10 11//=collection
Returns Feature<GeometryCollection> a GeoJSON GeometryCollection Feature
round
Round number to precision
Parameters
Examples
1turf.round(120.4321) 2//=120 3 4turf.round(120.4321, 2) 5//=120.43
Returns number rounded number
radiansToLength
Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
Parameters
radians
number in radians across the sphereunits
string can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default'kilometers'
)
Returns number distance
lengthToRadians
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
Parameters
distance
number in real unitsunits
string can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default'kilometers'
)
Returns number radians
lengthToDegrees
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
Parameters
distance
number in real unitsunits
string can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default'kilometers'
)
Returns number degrees
bearingToAzimuth
Converts any bearing angle from the north line direction (positive clockwise) and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
Parameters
bearing
number angle, between -180 and +180 degrees
Returns number angle between 0 and 360 degrees
radiansToDegrees
Converts an angle in radians to degrees
Parameters
radians
number angle in radians
Returns number degrees between 0 and 360 degrees
degreesToRadians
Converts an angle in degrees to radians
Parameters
degrees
number angle between 0 and 360 degrees
Returns number angle in radians
convertLength
Converts a length to the requested unit. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
Parameters
length
number to be convertedoriginalUnit
string of the lengthfinalUnit
string returned unit (optional, default'kilometers'
)
Returns number the converted length
convertArea
Converts a area to the requested unit. Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
Parameters
area
number to be convertedoriginalUnit
string of the distance (optional, default'meters'
)finalUnit
string returned unit (optional, default'kilometers'
)
Returns number the converted distance
isNumber
isNumber
Parameters
num
any Number to validate
Examples
1turf.isNumber(123) 2//=true 3turf.isNumber('foo') 4//=false
Returns boolean true/false
isObject
isObject
Parameters
input
any variable to validate
Examples
1turf.isObject({elevation: 10}) 2//=true 3turf.isObject('foo') 4//=false
Returns boolean true/false
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 module individually:
1$ npm install @turf/helpers
Or install the Turf module that includes it as a function:
1$ npm install @turf/turf
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: docs/SECURITY.md:1
- Info: Found linked content: docs/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: docs/SECURITY.md:1
- Info: Found text in security policy: docs/SECURITY.md:1
Reason
30 commit(s) and 16 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
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 9/10 approved changesets -- score normalized to 9
Reason
4 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-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 30 are checked with a SAST tool
Score
6.7
/10
Last Scanned on 2025-01-27
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