Turf.planepoint() calculates the z value for a point that falls on the plane of a triangle.

I am struggling to make this work with a tin from turf.tin() and a set of points.

Is there a turf function that returns the feature which contains a point?

Testing every triangle against every point isn't feasible.

Turf features doesn't seem to have IDs. I could create an ID for every triangle, then turf.tag() the IDs to the points and finally select the triangle from the tin feature set by this id before evaluating the turf.planepoint().

Ideally turf.planepoint() would accept feature collections but I could easily get there if I only could get the containing feature for each point.

1 Answer 1


Creating an integer index and turf.tag() the points with the integer index is pretty quick and works a treat. As a bonus I can use the index of the tin in the feature array, so the whole thing is pretty quick.

enter image description here

Here is a bit of code in case you are trying to replicate this.

var n = tin.features.length;
for (var i = 0; i < n; i++) {
    tin.features[i].properties.i = i;

var tagged_ = turf.tag(dots, tin, 'i', 'tin');
var n = tagged_.features.length;
for (var i = 0; i < n; i++) {
  if (tagged_.features[i].properties.tin) {
    tagged_.features[i].properties.dt = turf.planepoint(

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.