I am using contour.jl to plot extract contours from interpolated data. Let’s take the sample code from the documentation
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:
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.