# How to pick a cell from vtkPolyData by coordinate

**URL:** https://discourse.vtk.org/t/how-to-pick-a-cell-from-vtkpolydata-by-coordinate/9096
**Category:** Support
**Created:** [August 6, 2022, 11:17am UTC](https://discourse.vtk.org/t/how-to-pick-a-cell-from-vtkpolydata-by-coordinate/9096 "2022-08-06T11:17:28Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [August 7, 2022, 1:06pm UTC](https://discourse.vtk.org/t/how-to-pick-a-cell-from-vtkpolydata-by-coordinate/9096/4 "2022-08-07T13:06:40Z")

</div>

Hello,

I suggest you to study this example: [https://kitware.github.io/vtk-examples/site/Cxx/PolyData/CellLocator/](https://kitware.github.io/vtk-examples/site/Cxx/PolyData/CellLocator/)

In VTK context, a cell is any composition of `vtkPoint`s, which is a sort of atomic object. The simplest cell type is a vertex which is composed by a single “atom”. Other cell types include:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/542a06827c881ecd5c8a80347ba356eba762a896.png)

I belive you want to query the cell of type `VTK_LINE`(3) or `VTK_POLY_LINE`(4) that is near `clickedcoord[0]`, `clickedcoord[1]`, `clickedcoord[2]`. So you can set either `3` or `4` as the `subId` parameter of the `FindClosestPoint()` method in the example above.

**NOTICE VTK 9** : If you’re using VTK 9, be aware that the conversion to world coordinates in picking operations has a standing bug: [vtkPropPicker in VTK 9.1 is now returning wrong world coordinates.](https://discourse.vtk.org/t/vtkproppicker-in-vtk-9-1-is-now-returning-wrong-world-coordinates/8061) . I submitted a merge request with a possible solution here: [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/9125](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9125) . If you experience this bug and can’t wait for a solution to make it downstream, you can patch VTK yourself (like I did) as described here: [VTK 9: the pick marker is not positioned on the picked location, instead it is now placed in a plane orthogonal to the camera. · Issue #273 · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/issues/273#issuecomment-1107924892).

take care,

Paulo

---

_[View the full topic](https://discourse.vtk.org/t/how-to-pick-a-cell-from-vtkpolydata-by-coordinate/9096)._
