Retrieve Coordinates from Contour

Hi Everyone,

First email here…

I am plotting
meteorological data using matplotlib and basemap - and can do this just
fine. However, I would like to backout the coordinates being used for
the contours that are plotted.

For example, if I were to contour windspeed every 5 m/s and plot
this (which I can do just fine), I would like to save a copy of the
lat, lon pairs as a text file. However, I cannot for the life of me
figure out how to do this. I have a feeling it is pretty simple and
I’m just over looking something that can do this. Any help would be
appreciated.

Thanks,

-Patrick Marsh
Graduate Student
School of Meteorology
University of Oklahoma

Patrick Marsh wrote:

Hi Everyone,

First email here...

I am plotting meteorological data using matplotlib and basemap - and can do this just fine. However, I would like to backout the coordinates being used for the contours that are plotted.

For example, if I were to contour windspeed every 5 m/s and plot this (which I can do just fine), I would like to save a copy of the lat, lon pairs as a text file. However, I cannot for the life of me figure out how to do this. I have a feeling it is pretty simple and I'm just over looking something that can do this. Any help would be appreciated.

Thanks,

-Patrick Marsh
Graduate Student
School of Meteorology
University of Oklahoma

Patrick: contour and contourf return a ContourSet object. ContourSet.collections is a matplotlib LineCollection (for contour) or a PolyCollection (for contourf). You can retrieve the x,y (map projection) coordinates from these, and transfer them back to lat/lon coordinates using the Basemap instance via

lons,lats = map(x,y,inverse=True) # map is a Basemap instance.

See http://matplotlib.sourceforge.net/doc/html/api/collections_api.html for more info on matplotlib collection objects.

HTH,
-Jeff

···

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328