turf-helpers
feature
Wraps a GeoJSON Geometry in a GeoJSON Feature.
Parameters
geometry
Geometry input geometryproperties
Object properties
Examples
var geometry = "type": "Point" "coordinates": 675 3284267363195431 var feature = turf; //=feature
Returns FeatureCollection a FeatureCollection of input features
point
Takes coordinates and properties (optional) and returns a new Point feature.
Parameters
coordinates
Array<number> longitude, latitude position (each in decimal degrees)properties
[Object] an Object that is used as the Feature's properties
Examples
var pt1 = turf; //=pt1
Returns Feature<Point> a Point feature
polygon
Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
Parameters
coordinates
Array<Array<Array<number>>> an array of LinearRingsproperties
[Object] a properties object
Examples
var polygon = turf; //=polygon
- Throws Error throw an error if a LinearRing of the polygon has too few positions or if a LinearRing of the Polygon does not have matching Positions at the beginning & end.
Returns Feature<Polygon> a Polygon feature
lineString
Creates a LineString 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
Examples
var linestring1 = turf;var linestring2 = turf; //=linestring1 //=linestring2
- Throws Error if no coordinates are passed
Returns Feature<LineString> a LineString feature
featureCollection
Takes one or more Features and creates a FeatureCollection.
Parameters
features
Array<Feature> input features
Examples
var features = turf turf turf; var fc = turf; //=fc
Returns FeatureCollection a FeatureCollection of input 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
Examples
var multiLine = turf; //=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
Examples
var multiPt = turf; //=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
Examples
var multiPoly = turf; //=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
Examples
var pt = "type": "Point" "coordinates": 100 0 ;var line = "type": "LineString" "coordinates": 101 0 102 1 ;var collection = turf; //=collection
Returns Feature<GeometryCollection> a geometrycollection feature
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:
$ npm install turf-helpers
Or install the Turf module that includes it as a function:
$ npm install turf