# Get indices of points in convex hull

**URL:** <https://discourse.julialang.org/t/get-indices-of-points-in-convex-hull/116320>\
**Category:** General Usage\
**Created:** [June 27, 2024, 5:22pm UTC](https://discourse.julialang.org/t/get-indices-of-points-in-convex-hull/116320 "2024-06-27T17:22:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 27, 2024, 5:22pm UTC](https://discourse.julialang.org/t/get-indices-of-points-in-convex-hull/116320/1 "2024-06-27T17:22:58Z")

</div>

LazySets.jl contains the function `convex_hull`. to get the points that form the convex hull of a set of points.

```julia
julia> x = rand(10); y = rand(10);

julia> t = map(x, y) do xi, yi
           [xi, yi]
       end;

julia> h = convex_hull(t)
7-element Vector{Vector{Float64}}:
 [0.27874509698405914, 0.8381264273624781]
 [0.4204741719144459, 0.27569852706323217]
 [0.47489782426354443, 0.22189599344415556]
 [0.8408411037903044, 0.08270095905730068]
 [0.9695545294784288, 0.08977018366438483]
 [0.7769612361366431, 0.6925328658255991]
 [0.44161422504009307, 0.8354916368597441]

```

Is there any way to get the _indices_ of these points, rather than the points themselves?

---

<div class="post-metadata">

**Author:** ![mforets](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mforets/32/298_2.png) [@mforets](https://discourse.julialang.org/u/mforets)\
**Post date:** [July 1, 2024, 2:51pm UTC](https://discourse.julialang.org/t/get-indices-of-points-in-convex-hull/116320/2 "2024-07-01T14:51:54Z")

</div>

There isn’t, but you could use the built-in `indexin` function between `t` and `h`.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [July 4, 2024, 3:14pm UTC](https://discourse.julialang.org/t/get-indices-of-points-in-convex-hull/116320/3 "2024-07-04T15:14:04Z")

</div>

As an alternative, this lightweight package can give you the indices. [GitHub - jw3126/ConvexHulls2d.jl: Simple and lightweight convex hull in 2d](https://github.com/jw3126/ConvexHulls2d.jl)
