I have the following list of points and would like to know how I can find the sublist (i.e. point) which has a closest X and Y value to the X and Y value of a specific point (e.g here b1 ={{-20.6105, -290.292, -1914.28}}). I tried to use the following script but no answer.


B5 = Select[Data3D1, MemberQ[#, 
    Nearest[Data3D1[[All, 1]], b1[[1]]] && 
     Nearest[Data3D1[[All, 2]], b1[[2]]]] &]```

  • $\begingroup$ It's possible that the nearest y coordinate and the nearest x coordinate belong to two different points. Do you want the EuclideanDistance or ManhattanDistance instead? $\endgroup$
    – flinty
    Jul 1 '20 at 20:57
  • $\begingroup$ Thank you flinty! Not sure, maybe EuclideanDistance works. I almost know which point I need from drawing but can not get that point coordinate. $\endgroup$ Jul 1 '20 at 21:02
  • 3
    $\begingroup$ If you want to find the closest point in x,y ignoring the z coordinate, then do nf = Nearest[Data3D1, DistanceFunction -> Function[{p, q}, EuclideanDistance[Most[p], Most[q]]]]; - this will return a NearestFunction which you can use repeatedly which is more efficient. Try: nf[{-20.6105, -290.292, -1914.28}] $\endgroup$
    – flinty
    Jul 1 '20 at 21:04

Your Answer

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

Browse other questions tagged or ask your own question.