I am using turf.js for geometrical operation on openlayers3 features but i think it lacks support for "contains" operation.

There are these within and inside operations, but they return "false" when i check it with the polygon. Is there any other way to do this "contains" operation with turf.js or do i have to use the JSTS?

  • JSTS is a better solution in my personal opinion. But in your case if a point is within a polygon then this polygon contains your point.
    – pavlos
    Nov 1, 2015 at 15:29
  • Thanks @pavlos for reply, but my requirement is not to check the point within polygon, but polygon contains "polygon". And yeah may be looping through the coordinates of 2nd polygon and then checking the "within" to first polygon solves the problem, but that becomes an unnecessary task.
    – Suraj
    Nov 1, 2015 at 17:51
  • 1
    Much of Turf has relied on JSTS it turns out: github.com/Turfjs/turf/issues/88
    – thadk
    Jul 5, 2016 at 18:27
  • 1
    Not really knowing anything about either of these prior to a few hours ago, I'd say turf is far better documented than JSTS. With JSTS all I could find was a link the the Java API and a site with about 4 examples. Am I missing something?
    – redbmk
    Aug 2, 2016 at 16:49
  • 1
    @redbmk In case it helps I managed to track down the JSTS API here: bjornharrtell.github.io/jsts/doc/api Mar 8, 2017 at 10:22

1 Answer 1


You should be able to use the turf/boolean-contains module, noting that this only returns a true or false answer. Hope that helps

  • Given that this question was asked in '15. And currently i am not working on the same, yet the description on at the URL shared seems like finally this support is added to turf.js. Hence accepting this as answer.
    – Suraj
    Jan 12, 2018 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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