I'm working on a buffer analysis and then intersection using turf.js. I have a buffered output layer to which I need to intersect another polygon layer and get the output. Below is my code,

        function calculateBuffer() {
            var fc1 = turf.featureCollection(fc1Layer.getLayers().map(function(f){
                    return f.toGeoJSON()

            var buffer = turf.buffer(fc1, 5, 'kilometers');
            buffer.properties = {
                "fill": "#6BC65F",
                "stroke": "#25561F",
                "stroke-width": 2
           //var bufferGeojson=bufferLayer.setGeoJSON(buffer);
    //polygon layer//
            var fc = turf.featureCollection(fcLayer.getLayers().map(function(f){
                    return f.toGeoJSON()
    //buffer layer//
             var buffer = turf.featureCollection(bufferLayer.getLayers().map(function(f){
                    return f.toGeoJSON()
            var polygon = turf.intersect(fc,buffer);
        polygon.properties = {
            "fill": "#25561F",
            "stroke": "#25561F",
            "stroke-width": 10

I'm getting the following error:turf.min.js:16 Uncaught TypeError: o.intersection is not a function. Could anyone help me on this?


I think turf.intersect() takes only single features with Polygon geometry as arguments.

You should separate your layers into individual Polygons and compute the intersection between your 2 sets of Polygons by iteration.

  • As you said I took two individual polygons and tried intersection as two different geojson file. but still it gives me the same error.
    – Bruce
    Aug 3 '16 at 11:26
  • Please would you be able to reproduce your issue on an online editing service, like Plunker, JSFiddle, JSBin, etc.?
    – ghybs
    Aug 3 '16 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.