<div dir="ltr"><div><div><div>Hello,<br></div>         I have data on a 2d lat lon grid(equal grid spacing) in terms of laitude and longitude and heights as enclosed in the image. I need the coordinates(in terms of latitude and longitude) of the contours( as shown in red in the image). From this answer - <a href="https://stackoverflow.com/questions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/">https://stackoverflow.com/questions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/</a> will this give me what I am looking for or is there a scaling required to latitude and longitude that I need to include? <br><br></div>Best regards,<br></div>Ashwin. <br><div><div><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-kwd">import</span><span class="gmail-pln"> numpy </span><span class="gmail-kwd">as</span><span class="gmail-pln"> np

</span><span class="gmail-kwd">def</span><span class="gmail-pln"> get_contour_verts</span><span class="gmail-pun">(</span><span class="gmail-pln">cn</span><span class="gmail-pun">):</span><span class="gmail-pln">
    contours </span><span class="gmail-pun">=</span><span class="gmail-pln"> </span><span class="gmail-pun">[]</span><span class="gmail-pln">
    </span><span class="gmail-com"># for each contour line</span><span class="gmail-pln">
    </span><span class="gmail-kwd">for</span><span class="gmail-pln"> cc </span><span class="gmail-kwd">in</span><span class="gmail-pln"> cn</span><span class="gmail-pun">.</span><span class="gmail-pln">collections</span><span class="gmail-pun">:</span><span class="gmail-pln">
        paths </span><span class="gmail-pun">=</span><span class="gmail-pln"> </span><span class="gmail-pun">[]</span><span class="gmail-pln">
        </span><span class="gmail-com"># for each separate section of the contour line</span><span class="gmail-pln">
        </span><span class="gmail-kwd">for</span><span class="gmail-pln"> pp </span><span class="gmail-kwd">in</span><span class="gmail-pln"> cc</span><span class="gmail-pun">.</span><span class="gmail-pln">get_paths</span><span class="gmail-pun">():</span><span class="gmail-pln">
            xy </span><span class="gmail-pun">=</span><span class="gmail-pln"> </span><span class="gmail-pun">[]</span><span class="gmail-pln">
            </span><span class="gmail-com"># for each segment of that section</span><span class="gmail-pln">
            </span><span class="gmail-kwd">for</span><span class="gmail-pln"> vv </span><span class="gmail-kwd">in</span><span class="gmail-pln"> pp</span><span class="gmail-pun">.</span><span class="gmail-pln">iter_segments</span><span class="gmail-pun">():</span><span class="gmail-pln">
                xy</span><span class="gmail-pun">.</span><span class="gmail-pln">append</span><span class="gmail-pun">(</span><span class="gmail-pln">vv</span><span class="gmail-pun">[</span><span class="gmail-lit">0</span><span class="gmail-pun">])</span><span class="gmail-pln">
            paths</span><span class="gmail-pun">.</span><span class="gmail-pln">append</span><span class="gmail-pun">(</span><span class="gmail-pln">np</span><span class="gmail-pun">.</span><span class="gmail-pln">vstack</span><span class="gmail-pun">(</span><span class="gmail-pln">xy</span><span class="gmail-pun">))</span><span class="gmail-pln">
        contours</span><span class="gmail-pun">.</span><span class="gmail-pln">append</span><span class="gmail-pun">(</span><span class="gmail-pln">paths</span><span class="gmail-pun">)</span><span class="gmail-pln">

    </span><span class="gmail-kwd">return</span><span class="gmail-pln"> contours<br><br></span></code></pre><pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln"><br></span></code></pre></div></div></div>