Global

Members

bbox

Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
Source:
Example
var pt1 = turf.point([114.175329, 22.2524])
var pt2 = turf.point([114.170007, 22.267969])
var pt3 = turf.point([114.200649, 22.274641])
var pt4 = turf.point([114.200649, 22.274641])
var pt5 = turf.point([114.186744, 22.265745])
var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5])

var bbox = turf.bbox(features);

var bboxPolygon = turf.bboxPolygon(bbox);

//=bbox

//=bboxPolygon

bbox

Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
Source:
Example
var pt1 = turf.point([114.175329, 22.2524])
var pt2 = turf.point([114.170007, 22.267969])
var pt3 = turf.point([114.200649, 22.274641])
var pt4 = turf.point([114.200649, 22.274641])
var pt5 = turf.point([114.186744, 22.265745])
var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5])

var bbox = turf.bbox(features);

var bboxPolygon = turf.bboxPolygon(bbox);

//=bbox

//=bboxPolygon

bbox-clip

Takes a Feature and a bbox and clips the feature to the bbox using [lineclip](https://github.com/mapbox/lineclip). May result in degenerate edges when clipping Polygons.
Source:
Example
var bbox = [0, 0, 10, 10];
var poly = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]
  }
}

var clipped = turf.bboxClip(poly, bbox);

//=clipped

bbox-clip

Takes a Feature and a bbox and clips the feature to the bbox using [lineclip](https://github.com/mapbox/lineclip). May result in degenerate edges when clipping Polygons.
Source:
Example
var bbox = [0, 0, 10, 10];
var poly = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]
  }
}

var clipped = turf.bboxClip(poly, bbox);

//=clipped

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
Source:

buffer

Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.
Source:
Example
var pt = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [-90.548630, 14.616599]
  }
};
var unit = 'miles';

var buffered = turf.buffer(pt, 500, unit);
var result = turf.featureCollection([buffered, pt]);

//=result

center

Takes a Feature or FeatureCollection and returns the absolute center point of all features.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.522259, 35.4691]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.502754, 35.463455]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.508269, 35.463245]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.516809, 35.465779]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.515372, 35.467072]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.509363, 35.463053]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.511123, 35.466601]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.518547, 35.469327]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.519706, 35.469659]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.517839, 35.466998]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.508678, 35.464942]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-97.514914, 35.463453]
      }
    }
  ]
};

var centerPt = turf.center(features);
centerPt.properties['marker-size'] = 'large';
centerPt.properties['marker-color'] = '#000';

var resultFeatures = features.features.concat(centerPt);
var result = {
  "type": "FeatureCollection",
  "features": resultFeatures
};

//=result

centroid

Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
Source:
Example
var poly = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [105.818939,21.004714],
      [105.818939,21.061754],
      [105.890007,21.061754],
      [105.890007,21.004714],
      [105.818939,21.004714]
    ]]
  }
};

var centroidPt = turf.centroid(poly);

var result = {
  "type": "FeatureCollection",
  "features": [poly, centroidPt]
};

//=result

collectionOf

Enforce expectations about types of FeatureCollection inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

collectionOf

Enforce expectations about types of FeatureCollection inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

collectionOf

Enforce expectations about types of FeatureCollection inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

containsNumber

Checks if coordinates contains a number
Source:

containsNumber

Checks if coordinates contains a number
Source:

containsNumber

Checks if coordinates contains a number
Source:

convex

Takes a Feature or a FeatureCollection and returns a convex hull Polygon. Internally this uses the [convex-hull](https://github.com/mikolalysenko/convex-hull) module that implements a [monotone chain hull](http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain).
Source:
Example
var points = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.195312, 43.755225]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.404052, 43.8424511]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.579833, 43.659924]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.360107, 43.516688]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.14038, 43.588348]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [10.195312, 43.755225]
      }
    }
  ]
};

var hull = turf.convex(points);

var resultFeatures = points.features.concat(hull);
var result = {
  "type": "FeatureCollection",
  "features": resultFeatures
};

//=result

coordAll

Get all coordinates from any GeoJSON object.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
var coords = turf.coordAll(features);
//=coords

coordAll

Get all coordinates from any GeoJSON object.
Source:
Example
var features = turf.featureCollection([
  turf.point([26, 37], {foo: 'bar'}),
  turf.point([36, 53], {hello: 'world'})
]);

var coords = turf.coordAll(features);
//= [[26, 37], [36, 53]]

coordAll

Get all coordinates from any GeoJSON object.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
var coords = turf.coordAll(features);
//=coords

coordAll

Get all coordinates from any GeoJSON object.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
var coords = turf.coordAll(features);
//=coords

coordEach

Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordEach(features, function (currentCoords, currentIndex) {
  //=currentCoords
  //=currentIndex
});

coordEach

Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = turf.featureCollection([
  turf.point([26, 37], {"foo": "bar"}),
  turf.point([36, 53], {"hello": "world"})
]);

turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  //=currentCoord
  //=coordIndex
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
});

coordEach

Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordEach(features, function (currentCoords, currentIndex) {
  //=currentCoords
  //=currentIndex
});

coordEach

Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordEach(features, function (currentCoords, currentIndex) {
  //=currentCoords
  //=currentIndex
});

coordReduce

Reduce coordinates in any GeoJSON object, similar to Array.reduce()
Source:
Example
var features = turf.featureCollection([
  turf.point([26, 37], {"foo": "bar"}),
  turf.point([36, 53], {"hello": "world"})
]);

turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  //=previousValue
  //=currentCoord
  //=coordIndex
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
  return currentCoord;
});

coordReduce

Reduce coordinates in any GeoJSON object, similar to Array.reduce()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordReduce(features, function (previousValue, currentCoords, currentIndex) {
  //=previousValue
  //=currentCoords
  //=currentIndex
  return currentCoords;
});

coordReduce

Reduce coordinates in any GeoJSON object, similar to Array.reduce()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordReduce(features, function (previousValue, currentCoords, currentIndex) {
  //=previousValue
  //=currentCoords
  //=currentIndex
  return currentCoords;
});

coordReduce

Reduce coordinates in any GeoJSON object, similar to Array.reduce()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.coordReduce(features, function (previousValue, currentCoords, currentIndex) {
  //=previousValue
  //=currentCoords
  //=currentIndex
  return currentCoords;
});

degreesToRadians

Converts an angle in degrees to radians
Source:

difference

Finds the difference between two polygons by clipping the second polygon from the first.
Source:
Example
var poly1 = {
  "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.738586, -23.596711],
      [-46.738586, -23.458207],
      [-46.560058, -23.458207],
      [-46.560058, -23.596711],
      [-46.738586, -23.596711]
    ]]
  }
};
var poly2 = {
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.650009, -23.631314],
      [-46.650009, -23.5237],
      [-46.509246, -23.5237],
      [-46.509246, -23.631314],
      [-46.650009, -23.631314]
    ]]
  }
};

var differenced = turf.difference(poly1, poly2);
differenced.properties.fill = '#f00';

var polygons = {
  "type": "FeatureCollection",
  "features": [poly1, poly2]
};

//=polygons

//=differenced

distanceToDegrees

Convert a distance measurement from a real-world unit into degrees
Source:

distanceToDegrees

Convert a distance measurement from a real-world unit into degrees
Source:

distanceToRadians

Convert a distance measurement from a real-world unit into radians
Source:

distanceToRadians

Convert a distance measurement from a real-world unit into radians
Source:

explode

Takes a feature or set of features and returns all positions as points.
Source:
Example
var poly = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [177.434692, -17.77517],
      [177.402076, -17.779093],
      [177.38079, -17.803937],
      [177.40242, -17.826164],
      [177.438468, -17.824857],
      [177.454948, -17.796746],
      [177.434692, -17.77517]
    ]]
  }
};

var points = turf.explode(poly);

//=poly

//=points

feature

Wraps a GeoJSON Geometry in a GeoJSON Feature.
Source:
Example
var geometry = {
     "type": "Point",
     "coordinates": [
       67.5,
       32.84267363195431
     ]
   }

var feature = turf.feature(geometry);

//=feature

feature

Wraps a GeoJSON Geometry in a GeoJSON Feature.
Source:
Example
var geometry = {
  "type": "Point",
  "coordinates": [110, 50]
};

var feature = turf.feature(geometry);

//=feature

feature

Wraps a GeoJSON Geometry in a GeoJSON Feature.
Source:
Example
var geometry = {
     "type": "Point",
     "coordinates": [
       67.5,
       32.84267363195431
     ]
   }

var feature = turf.feature(geometry);

//=feature

feature

Wraps a GeoJSON Geometry in a GeoJSON Feature.
Source:
Example
var geometry = {
     "type": "Point",
     "coordinates": [
       67.5,
       32.84267363195431
     ]
   }

var feature = turf.feature(geometry);

//=feature

featureCollection

Takes one or more Features and creates a FeatureCollection.
Source:
Example
var features = [
 turf.point([-75.343, 39.984], {name: 'Location A'}),
 turf.point([-75.833, 39.284], {name: 'Location B'}),
 turf.point([-75.534, 39.123], {name: 'Location C'})
];

var fc = turf.featureCollection(features);

//=fc

featureCollection

Takes one or more Features and creates a FeatureCollection.
Source:
Example
var features = [
 turf.point([-75.343, 39.984], {name: 'Location A'}),
 turf.point([-75.833, 39.284], {name: 'Location B'}),
 turf.point([-75.534, 39.123], {name: 'Location C'})
];

var fc = turf.featureCollection(features);

//=fc

featureCollection

Takes one or more Features and creates a FeatureCollection.
Source:
Example
var features = [
 turf.point([-75.343, 39.984], {name: 'Location A'}),
 turf.point([-75.833, 39.284], {name: 'Location B'}),
 turf.point([-75.534, 39.123], {name: 'Location C'})
];

var fc = turf.featureCollection(features);

//=fc

featureCollection

Takes one or more Features and creates a FeatureCollection.
Source:
Example
var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});

var collection = turf.featureCollection([
  locationA,
  locationB,
  locationC
]);

//=collection

featureEach

Iterate over features in any GeoJSON object, similar to Array.forEach.
Source:
Example
var features = turf.featureCollection([
  turf.point([26, 37], {foo: 'bar'}),
  turf.point([36, 53], {hello: 'world'})
]);

turf.featureEach(features, function (currentFeature, featureIndex) {
  //=currentFeature
  //=featureIndex
});

featureEach

Iterate over features in any GeoJSON object, similar to Array.forEach.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureEach(features, function (currentFeature, currentIndex) {
  //=currentFeature
  //=currentIndex
});

featureEach

Iterate over features in any GeoJSON object, similar to Array.forEach.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureEach(features, function (currentFeature, currentIndex) {
  //=currentFeature
  //=currentIndex
});

featureEach

Iterate over features in any GeoJSON object, similar to Array.forEach.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureEach(features, function (currentFeature, currentIndex) {
  //=currentFeature
  //=currentIndex
});

featureOf

Enforce expectations about types of Feature inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

featureOf

Enforce expectations about types of Feature inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

featureOf

Enforce expectations about types of Feature inputs for Turf. Internally this uses geojsonType to judge geometry types.
Source:

featureReduce

Reduce features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureReduce(features, function (previousValue, currentFeature, currentIndex) {
  //=previousValue
  //=currentFeature
  //=currentIndex
  return currentFeature
});

featureReduce

Reduce features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = turf.featureCollection([
  turf.point([26, 37], {"foo": "bar"}),
  turf.point([36, 53], {"hello": "world"})
]);

turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
  //=previousValue
  //=currentFeature
  //=featureIndex
  return currentFeature
});

featureReduce

Reduce features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureReduce(features, function (previousValue, currentFeature, currentIndex) {
  //=previousValue
  //=currentFeature
  //=currentIndex
  return currentFeature
});

featureReduce

Reduce features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.featureReduce(features, function (previousValue, currentFeature, currentIndex) {
  //=previousValue
  //=currentFeature
  //=currentIndex
  return currentFeature
});

flatten

Flattens any GeoJSON to a FeatureCollection inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
Source:
Example
var geometry = {
  "type": "MultiPolygon",
  "coordinates": [
    [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
     [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
     [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
   ]
 };

var flattened = turf.flatten(geometry);

//=flattened

flatten

Flattens any GeoJSON to a FeatureCollection inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
Source:
Example
var geometry = {
  "type": "MultiPolygon",
  "coordinates": [
    [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
     [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
     [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
   ]
 };

var flattened = turf.flatten(geometry);

//=flattened

flattenEach

Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
]);

turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) {
  //=currentFeature
  //=featureIndex
  //=multiFeatureIndex
});

flattenReduce

Reduce flattened features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
]);

turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {
  //=previousValue
  //=currentFeature
  //=featureIndex
  //=multiFeatureIndex
  return currentFeature
});

geojsonType

Enforce expectations about types of GeoJSON objects for Turf.
Source:

geojsonType

Enforce expectations about types of GeoJSON objects for Turf.
Source:

geojsonType

Enforce expectations about types of GeoJSON objects for Turf.
Source:

geomEach

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.point([36, 53], {hello: 'world'})
]);

turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
  //=currentGeometry
  //=featureIndex
  //=featureProperties
  //=featureBBox
  //=featureId
});

geomEach

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomEach(features, function (currentGeometry, currentIndex) {
  //=currentGeometry
  //=currentIndex
});

geomEach

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomEach(features, function (currentGeometry, currentIndex) {
  //=currentGeometry
  //=currentIndex
});

geomEach

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomEach(features, function (currentGeometry, currentIndex) {
  //=currentGeometry
  //=currentIndex
});

geometry

Creates a GeoJSON Geometry from a Geometry string type & coordinates. For GeometryCollection type use `helpers.geometryCollection`
Source:
Example
var type = 'Point';
var coordinates = [110, 50];

var geometry = turf.geometry(type, coordinates);

//=geometry

geometryCollection

Creates a Feature.<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Source:
Example
var pt = {
    "type": "Point",
      "coordinates": [100, 0]
    };
var line = {
    "type": "LineString",
    "coordinates": [ [101, 0], [102, 1] ]
  };
var collection = turf.geometryCollection([pt, line]);

//=collection

geometryCollection

Creates a Feature.<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Source:
Example
var pt = {
    "type": "Point",
      "coordinates": [100, 0]
    };
var line = {
    "type": "LineString",
    "coordinates": [ [101, 0], [102, 1] ]
  };
var collection = turf.geometryCollection([pt, line]);

//=collection

geometryCollection

Creates a Feature.<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Source:
Example
var pt = {
    "type": "Point",
      "coordinates": [100, 0]
    };
var line = {
    "type": "LineString",
    "coordinates": [ [101, 0], [102, 1] ]
  };
var collection = turf.geometryCollection([pt, line]);

//=collection

geometryCollection

Creates a Feature.<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Source:
Example
var pt = {
    "type": "Point",
      "coordinates": [100, 0]
    };
var line = {
    "type": "LineString",
    "coordinates": [ [101, 0], [102, 1] ]
  };
var collection = turf.geometryCollection([pt, line]);

//=collection

geomReduce

Reduce geometry in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomReduce(features, function (previousValue, currentGeometry, currentIndex) {
  //=previousValue
  //=currentGeometry
  //=currentIndex
  return currentGeometry
});

geomReduce

Reduce geometry in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomReduce(features, function (previousValue, currentGeometry, currentIndex) {
  //=previousValue
  //=currentGeometry
  //=currentIndex
  return currentGeometry
});

geomReduce

Reduce geometry in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.point([36, 53], {hello: 'world'})
]);

turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
  //=previousValue
  //=currentGeometry
  //=featureIndex
  //=featureProperties
  //=featureBBox
  //=featureId
  return currentGeometry
});

geomReduce

Reduce geometry in any GeoJSON object, similar to Array.reduce().
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.geomReduce(features, function (previousValue, currentGeometry, currentIndex) {
  //=previousValue
  //=currentGeometry
  //=currentIndex
  return currentGeometry
});

getCoord

Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
Source:

getCoord

Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
Source:

getCoord

Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
Source:
Example
var pt = turf.point([10, 10]);

var coord = turf.getCoord(pt);
//= [10, 10]

getCoords

Unwrap coordinates from a Feature, Geometry Object or an Array of numbers
Source:

getCoords

Unwrap coordinates from a Feature, Geometry Object or an Array
Source:
Example
var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);

var coords = turf.getCoords(poly);
//= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]

getCoords

Unwrap coordinates from a Feature, Geometry Object or an Array of numbers
Source:

inside

Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
Source:
Example
var pt = turf.point([-77, 44]);
var poly = turf.polygon([[
  [-81, 41],
  [-81, 47],
  [-72, 47],
  [-72, 41],
  [-81, 41]
]]);

var isInside = turf.inside(pt, poly);

//=isInside

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
Source:

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
Source:

lineEach

Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.
Source:
Example
var multiLine = turf.multiLineString([
  [[26, 37], [35, 45]],
  [[36, 53], [38, 50], [41, 55]]
]);

turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
  //=currentLine
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
});

lineIntersect

Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
Source:
Example
var line1 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[126, -11], [129, -21]]
  }
};
var line2 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[123, -18], [131, -14]]
  }
};
var points = turf.lineIntersect(line1, line2);
//= points

lineIntersect

Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
Source:
Example
var line1 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[126, -11], [129, -21]]
  }
};
var line2 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [[123, -18], [131, -14]]
  }
};
var points = turf.lineIntersect(line1, line2);
//= points

lineOffset

Takes a line and returns a line at offset by the specified distance.
Source:
Example
var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" });

var offsetLine = turf.lineOffset(line, 2, {units: 'miles'});

//addToMap
var addToMap = [offsetLine, line]
offsetLine.properties.stroke = "#00F"

lineReduce

Reduce features in any GeoJSON object, similar to Array.reduce().
Source:
Example
var multiPoly = turf.multiPolygon([
  turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
  turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
]);

turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
  //=previousValue
  //=currentLine
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
  return currentLine
});

lineSegment

Creates a FeatureCollection of 2-vertex LineString segments from a LineString, MultiLineString, MultiPolygon or Polygon.
Source:
Example
var polygon = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]
  }
}
var segments = turf.lineSegment(polygon);
//=segments

lineSegment

Creates a FeatureCollection of 2-vertex LineString segments from a LineString, MultiLineString, MultiPolygon or Polygon.
Source:
Example
var polygon = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]
  }
}
var segments = turf.lineSegment(polygon);
//=segments

lineString

Creates a LineString Feature from an Array of Positions.
Source:
Example
var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});

//=linestring1
//=linestring2

lineString

Creates a LineString based on a coordinate array. Properties can be added optionally.
Source:
Example
var linestring1 = turf.lineString([
  [-21.964416, 64.148203],
  [-21.956176, 64.141316],
  [-21.93901, 64.135924],
  [-21.927337, 64.136673]
]);
var linestring2 = turf.lineString([
  [-21.929054, 64.127985],
  [-21.912918, 64.134726],
  [-21.916007, 64.141016],
  [-21.930084, 64.14446]
], {name: 'line 1', distance: 145});

//=linestring1

//=linestring2

lineString

Creates a LineString based on a coordinate array. Properties can be added optionally.
Source:
Example
var linestring1 = turf.lineString([
  [-21.964416, 64.148203],
  [-21.956176, 64.141316],
  [-21.93901, 64.135924],
  [-21.927337, 64.136673]
]);
var linestring2 = turf.lineString([
  [-21.929054, 64.127985],
  [-21.912918, 64.134726],
  [-21.916007, 64.141016],
  [-21.930084, 64.14446]
], {name: 'line 1', distance: 145});

//=linestring1

//=linestring2

lineString

Creates a LineString based on a coordinate array. Properties can be added optionally.
Source:
Example
var linestring1 = turf.lineString([
  [-21.964416, 64.148203],
  [-21.956176, 64.141316],
  [-21.93901, 64.135924],
  [-21.927337, 64.136673]
]);
var linestring2 = turf.lineString([
  [-21.929054, 64.127985],
  [-21.912918, 64.134726],
  [-21.916007, 64.141016],
  [-21.930084, 64.14446]
], {name: 'line 1', distance: 145});

//=linestring1

//=linestring2

lineStrings

Creates a LineString FeatureCollection from an Array of LineString coordinates.
Source:
Example
var linestrings = turf.lineStrings([
  [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
  [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
]);

//=linestrings

mask

Takes any type of polygon and an optional mask and returns a polygon exterior ring with holes.
Source:
Example
var polygon = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[112, -21], [116, -36], [146, -39], [153, -24], [133, -10], [112, -21]]]
  }
}
var mask = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[[90, -55], [170, -55], [170, 10], [90, 10], [90, -55]]]
  }
}
var masked = turf.mask(polygon, mask);
//=masked

multiLineString

Creates a Feature.<MultiLineString> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);

//=multiLine

multiLineString

Creates a Feature.<MultiLineString> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);

//=multiLine

multiLineString

Creates a Feature.<MultiLineString> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);

//=multiLine

multiLineString

Creates a Feature.<MultiLineString> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);

//=multiLine

multiPoint

Creates a Feature.<MultiPoint> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPt = turf.multiPoint([[0,0],[10,10]]);

//=multiPt

multiPoint

Creates a Feature.<MultiPoint> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPt = turf.multiPoint([[0,0],[10,10]]);

//=multiPt

multiPoint

Creates a Feature.<MultiPoint> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPt = turf.multiPoint([[0,0],[10,10]]);

//=multiPt

multiPoint

Creates a Feature.<MultiPoint> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPt = turf.multiPoint([[0,0],[10,10]]);

//=multiPt

multiPolygon

Creates a Feature.<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);

//=multiPoly

multiPolygon

Creates a Feature.<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);

//=multiPoly

multiPolygon

Creates a Feature.<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);

//=multiPoly

multiPolygon

Creates a Feature.<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Source:
Example
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);

//=multiPoly

point

Takes coordinates and properties (optional) and returns a new Point feature.
Source:
Example
var pt1 = turf.point([-75.343, 39.984]);

//=pt1

point

Takes coordinates and properties (optional) and returns a new Point feature.
Source:
Example
var pt1 = turf.point([-75.343, 39.984]);

//=pt1

point

Takes coordinates and properties (optional) and returns a new Point feature.
Source:
Example
var pt1 = turf.point([-75.343, 39.984]);

//=pt1

point

Creates a Point Feature from a Position.
Source:
Example
var point = turf.point([-75.343, 39.984]);

//=point

points

Creates a Point FeatureCollection from an Array of Point coordinates.
Source:
Example
var points = turf.points([
  [-75, 39],
  [-80, 45],
  [-78, 50]
]);

//=points

polygon

Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
Source:
Example
var polygon = turf.polygon([[
 [-2.275543, 53.464547],
 [-2.275543, 53.489271],
 [-2.215118, 53.489271],
 [-2.215118, 53.464547],
 [-2.275543, 53.464547]
]], { name: 'poly1', population: 400});

//=polygon

polygon

Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
Source:
Example
var polygon = turf.polygon([[
 [-2.275543, 53.464547],
 [-2.275543, 53.489271],
 [-2.215118, 53.489271],
 [-2.215118, 53.464547],
 [-2.275543, 53.464547]
]], { name: 'poly1', population: 400});

//=polygon

polygon

Creates a Polygon Feature from an Array of LinearRings.
Source:
Example
var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });

//=polygon

polygon

Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
Source:
Example
var polygon = turf.polygon([[
 [-2.275543, 53.464547],
 [-2.275543, 53.489271],
 [-2.215118, 53.489271],
 [-2.215118, 53.464547],
 [-2.275543, 53.464547]
]], { name: 'poly1', population: 400});

//=polygon

polygons

Creates a Polygon FeatureCollection from an Array of Polygon coordinates.
Source:
Example
var polygons = turf.polygons([
  [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
  [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
]);

//=polygons

polygonToLineString

Converts a Polygon or MultiPolygon to a FeatureCollection of LineString or MultiLineString.
Source:
Example
var poly = {
  'type': 'Feature',
  'properties': {},
  'geometry': {
    'type': 'Polygon',
    'coordinates': [[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]
  }
}
var lines = turf.polygonToLineString(poly);
//addToMap
var addToMap = [lines]

polygonToLineString

Converts a Polygon or MultiPolygon to a FeatureCollection of LineString or MultiLineString.
Source:
Example
var poly = {
  'type': 'Feature',
  'properties': {},
  'geometry': {
    'type': 'Polygon',
    'coordinates': [[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]
  }
}
var lines = turf.polygonToLineString(poly);
//addToMap
var addToMap = [lines]

propEach

Iterate over properties in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propEach(features, function (currentProperties, currentIndex) {
  //=currentProperties
  //=currentIndex
});

propEach

Iterate over properties in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.point([36, 53], {hello: 'world'})
]);

turf.propEach(features, function (currentProperties, featureIndex) {
  //=currentProperties
  //=featureIndex
});

propEach

Iterate over properties in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propEach(features, function (currentProperties, currentIndex) {
  //=currentProperties
  //=currentIndex
});

propEach

Iterate over properties in any GeoJSON object, similar to Array.forEach()
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propEach(features, function (currentProperties, currentIndex) {
  //=currentProperties
  //=currentIndex
});

propReduce

Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propReduce(features, function (previousValue, currentProperties, currentIndex) {
  //=previousValue
  //=currentProperties
  //=currentIndex
  return currentProperties
});

propReduce

Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propReduce(features, function (previousValue, currentProperties, currentIndex) {
  //=previousValue
  //=currentProperties
  //=currentIndex
  return currentProperties
});

propReduce

Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
Source:
Example
var features = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"foo": "bar"},
      "geometry": {
        "type": "Point",
        "coordinates": [26, 37]
      }
    },
    {
      "type": "Feature",
      "properties": {"hello": "world"},
      "geometry": {
        "type": "Point",
        "coordinates": [36, 53]
      }
    }
  ]
};
turf.propReduce(features, function (previousValue, currentProperties, currentIndex) {
  //=previousValue
  //=currentProperties
  //=currentIndex
  return currentProperties
});

propReduce

Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
Source:
Example
var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.point([36, 53], {hello: 'world'})
]);

turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
  //=previousValue
  //=currentProperties
  //=featureIndex
  return currentProperties
});

radiansToDegrees

Converts an angle in radians to degrees
Source:

radiansToDistance

Convert a distance measurement from radians to a more friendly unit.
Source:

radiansToDistance

Convert a distance measurement from radians to a more friendly unit.
Source:

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
Source:

rbush

GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.
Source:
Example
var rbush = require('geojson-rbush')
var tree = rbush()

rbush

GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.
Source:
Example
var rbush = require('geojson-rbush')
var tree = rbush()

simplify

Takes a LineString or Polygon and returns a simplified version. Internally uses [simplify-js](http://mourner.github.io/simplify-js/) to perform simplification.
Source:
Example
var feature = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-70.603637, -33.399918],
      [-70.614624, -33.395332],
      [-70.639343, -33.392466],
      [-70.659942, -33.394759],
      [-70.683975, -33.404504],
      [-70.697021, -33.419406],
      [-70.701141, -33.434306],
      [-70.700454, -33.446339],
      [-70.694274, -33.458369],
      [-70.682601, -33.465816],
      [-70.668869, -33.472117],
      [-70.646209, -33.473835],
      [-70.624923, -33.472117],
      [-70.609817, -33.468107],
      [-70.595397, -33.458369],
      [-70.587158, -33.442901],
      [-70.587158, -33.426283],
      [-70.590591, -33.414248],
      [-70.594711, -33.406224],
      [-70.603637, -33.399918]
    ]]
  }
};
var tolerance = 0.01;

var simplified = turf.simplify(
 feature, tolerance, false);

//=feature

//=simplified

union

Takes two or more polygons and returns a combined polygon. If the input polygons are not contiguous, this function returns a MultiPolygon feature.
Source:
Example
var poly1 = {
  "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-82.574787, 35.594087],
      [-82.574787, 35.615581],
      [-82.545261, 35.615581],
      [-82.545261, 35.594087],
      [-82.574787, 35.594087]
    ]]
  }
};
var poly2 = {
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-82.560024, 35.585153],
      [-82.560024, 35.602602],
      [-82.52964, 35.602602],
      [-82.52964, 35.585153],
      [-82.560024, 35.585153]
    ]]
  }
};
var polygons = {
  "type": "FeatureCollection",
  "features": [poly1, poly2]
};

var union = turf.union(poly1, poly2);

//=polygons

//=union

within

Takes a set of points and a set of polygons and returns the points that fall within the polygons.
Source:
Example
var searchWithin = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [[
          [-46.653,-23.543],
          [-46.634,-23.5346],
          [-46.613,-23.543],
          [-46.614,-23.559],
          [-46.631,-23.567],
          [-46.653,-23.560],
          [-46.653,-23.543]
        ]]
      }
    }
  ]
};
var points = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6318, -23.5523]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6246, -23.5325]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6062, -23.5513]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.663, -23.554]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.643, -23.557]
      }
    }
  ]
};

var ptsWithin = turf.within(points, searchWithin);

//=points

//=searchWithin

//=ptsWithin

Type Definitions

coordEachCallback(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex)

Callback for coordEach
Parameters:
Name Type Description
currentCoord Array.<number> The current coordinate being processed.
coordIndex number The current index of the coordinate being processed.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
geometryIndex number The current index of the Geometry being processed.
Source:

coordReduceCallback(previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex)

Callback for coordReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentCoord Array.<number> The current coordinate being processed.
coordIndex number The current index of the coordinate being processed. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
geometryIndex number The current index of the Geometry being processed.
Source:

featureEachCallback(currentFeature, featureIndex)

Callback for featureEach
Parameters:
Name Type Description
currentFeature Feature.<any> The current Feature being processed.
featureIndex number The current index of the Feature being processed.
Source:

featureReduceCallback(previousValue, currentFeature, featureIndex)

Callback for featureReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentFeature Feature The current Feature being processed.
featureIndex number The current index of the Feature being processed.
Source:

flattenEachCallback(currentFeature, featureIndex, multiFeatureIndex)

Callback for flattenEach
Parameters:
Name Type Description
currentFeature Feature The current flattened feature being processed.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
Source:

flattenReduceCallback(previousValue, currentFeature, featureIndex, multiFeatureIndex)

Callback for flattenReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentFeature Feature The current Feature being processed.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
Source:

geomEachCallback(currentGeometry, featureIndex, featureProperties, featureBBox, featureId)

Callback for geomEach
Parameters:
Name Type Description
currentGeometry Geometry The current Geometry being processed.
featureIndex number The current index of the Feature being processed.
featureProperties Object The current Feature Properties being processed.
featureBBox Array.<number> The current Feature BBox being processed.
featureId number | string The current Feature Id being processed.
Source:

geomReduceCallback(previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)

Callback for geomReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentGeometry Geometry The current Geometry being processed.
featureIndex number The current index of the Feature being processed.
featureProperties Object The current Feature Properties being processed.
featureBBox Array.<number> The current Feature BBox being processed.
featureId number | string The current Feature Id being processed.
Source:

lineEachCallback(currentLine, featureIndex, multiFeatureIndex, geometryIndex)

Callback for lineEach
Parameters:
Name Type Description
currentLine Feature.<LineString> The current LineString|LinearRing being processed
featureIndex number The current index of the Feature being processed
multiFeatureIndex number The current index of the Multi-Feature being processed
geometryIndex number The current index of the Geometry being processed
Source:

lineReduceCallback(previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)

Callback for lineReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentLine Feature.<LineString> The current LineString|LinearRing being processed.
featureIndex number The current index of the Feature being processed
multiFeatureIndex number The current index of the Multi-Feature being processed
geometryIndex number The current index of the Geometry being processed
Source:

propEachCallback(currentProperties, featureIndex)

Callback for propEach
Parameters:
Name Type Description
currentProperties Object The current Properties being processed.
featureIndex number The current index of the Feature being processed.
Source:

propReduceCallback(previousValue, currentProperties, featureIndex)

Callback for propReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentProperties * The current Properties being processed.
featureIndex number The current index of the Feature being processed.
Source:

segmentEachCallback(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) → {void}

Callback for segmentEach
Parameters:
Name Type Description
currentSegment Feature.<LineString> The current Segment being processed.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
geometryIndex number The current index of the Geometry being processed.
segmentIndex number The current index of the Segment being processed.
Source:
Returns:
Type
void

segmentReduceCallback(previousValue, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)

Callback for segmentReduce The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument. If an initialValue is provided to the reduce method: - The previousValue argument is initialValue. - The currentValue argument is the value of the first element present in the array. If an initialValue is not provided: - The previousValue argument is the value of the first element present in the array. - The currentValue argument is the value of the second element present in the array.
Parameters:
Name Type Description
previousValue * The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
currentSegment Feature.<LineString> The current Segment being processed.
featureIndex number The current index of the Feature being processed.
multiFeatureIndex number The current index of the Multi-Feature being processed.
geometryIndex number The current index of the Geometry being processed.
segmentIndex number The current index of the Segment being processed.
Source: