# Contour.jl: extract the indices of the contour

**URL:** <https://discourse.julialang.org/t/contour-jl-extract-the-indices-of-the-contour/51229>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [December 3, 2020, 11:54pm UTC](https://discourse.julialang.org/t/contour-jl-extract-the-indices-of-the-contour/51229 "2020-12-03T23:54:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ash](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@ash](https://discourse.julialang.org/u/ash)\
**Post date:** [December 3, 2020, 11:54pm UTC](https://discourse.julialang.org/t/contour-jl-extract-the-indices-of-the-contour/51229/1 "2020-12-03T23:54:24Z")

</div>

I am using contour.jl to plot extract contours from interpolated data. Let’s take the sample code from the documentation

```julia
for cl in levels(contours(x,y,z))
    lvl = level(cl) # the z-value of this contour level
    for line in lines(cl)
        xs, ys = coordinates(line) # coordinates of this line segment
    end
end

```

I need the indices of `xs` and `ys` in `x` and `y`, i.e.in a simple world this would be:

```julia
ix = indexin(xs, x)
iy = indexin(ys, y)
this_contour = z[ix, iy]

```

However, `xs` and `ys` do not belong exactly to `x` and `y`, and I can’t figure out how to extract the indices. Currently `indexin` returns some `int`s and some `nothing`s. I haven’t had much luck playing around with `round`.

The reason I need to do this is that I have an auxiliary array `w` that has the same shape as `z`, and I would like to extract the part corresponding to the contours for processing.

Is there some way to do this? I also opened an issue on their GitHub to see if the devs have any thoughts.

---

<div class="post-metadata">

**Author:** ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)\
**Post date:** [December 4, 2020, 3:31am UTC](https://discourse.julialang.org/t/contour-jl-extract-the-indices-of-the-contour/51229/2 "2020-12-04T03:31:24Z")

</div>

X-ref my response on github: [https://github.com/JuliaGeometry/Contour.jl/issues/66](https://github.com/JuliaGeometry/Contour.jl/issues/66)
