# ContourPlot - plot only one connected component

How do I plot only one component in ContourPlot when specifying a height.

For example,

ContourPlot[
Sin[Sqrt[x^2 + y^2]] Exp[-x^2 - y^2] == 0,
{x, -10, 10}, {y, -10, 10}
]

produces concentric circles. How do I plot only the innermost one? That is the component going through (Pi,0).

-

Contour closest to point:

x0={Pi,0}

Normal@ContourPlot[Sin[Sqrt[x^2 + y^2]] Exp[-x^2 - y^2] == 0, {x,-10,10}, {y,-10, 10},
PlotPoints -> 100
] /. {x_, y__Line} :> {x,
Line@SortBy[{y}[[;; , 1]], Min[Norm[# - x0] & /@ #] &][[1]]}

If you are aware of ther structure of graphics you can deal with such problems ad hoc:

ContourPlot[Sin[Sqrt[x^2 + y^2]] Exp[-x^2 - y^2] == 0, {x, -10, 10}, {y, -10, 10},
PlotPoints -> 100
] /. {col_, y__Line} :> {col, {y}[[-1]]}

That's not necessarily best way but the better network of information on SE the better! :)

So about the structure, you may want to take a look at:

Examine structure of graphics

-
How do you know which contour line this will be, other than testing? Is is always the innermost for example? –  Mr.Wizard Jan 31 at 7:10
@Mr.Wizard ofc not, best example is Sin[x]==0 where it's hard to tell what is innermost. I suspected it should be first or last one. That's why I called it ad hoc. :) I've provided an explanation why this was posted, if it works, why not ;) maybe someone will learn something. –  Kuba Jan 31 at 7:12
@Mr.Wizard ok, more general solution added. more convenient for not easy to set region functions. –  Kuba Jan 31 at 7:48
This seems good - I'll need to play around with it a bit. –  pdmclean Jan 31 at 9:39
@pdmclean I'm glad you like it :) It is good to hold on with an accept a day or two, better answers may appear while now others may feel discouraged ;) –  Kuba Jan 31 at 9:43