the vertex list should just be a list of two element tuples... which are the XY
positions of the verticies..
For example here is a function I used to split up individual closed contours:
--------------------------
def split_features(vertex_list):
#This function takes a list of verticies and breaks
#it into a list of shapes (ie a list of list of verticies)
#splits occur where a lon or lat jump of greater than 2 degrees
# is found... and given that most contouring algorithums
#work across the x-cord and our resolution is 1 degree this works..
jump_loc=[0]
for i in range(len(vertex_list)-1):
lon_jump=vertex_list[i+1][0]-vertex_list[i][0]
lat_jump=vertex_list[i+1][1]-vertex_list[i][1]
if (abs(lon_jump) > 2.0) or (abs(lat_jump) > 2.0):
jump_loc.append(i+1)
jump_loc.append(len(vertex_list)-1)
print jump_loc
shapes=[]
for i in range(len(jump_loc)-1):
shapes.append(vertex_list[jump_loc[i]:jump_loc[i+1]])
return shapes
------------------
Dr Scott Collis
Postdoctoral Researcher
Centre for Australian Weather and Climate Research (CAWCR)
Atmosphere and Land Observation and Assessment Group
Australian Bureau of Meteorology Room 9.57 Level 9 700 Collins Street Docklands
3008
Desk: (+613) 96694766
MB: 0412177550
http://www.bom.gov.au/bmrc/wefor/staff/scollis/
________________________________
Message: 3
Date: Sat, 2 Aug 2008 21:14:02 -0500
From: "Patrick Marsh" <[EMAIL PROTECTED]>
Subject: Re: [Matplotlib-users] Retrieve Coordinates from Contour
To: "Jeff Whitaker" <[EMAIL PROTECTED]>
Cc: matplotlib-users <matplotlib-users@lists.sourceforge.net>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
Hi Jeff (and others):
Sorry for the misunderstanding. After your second email the first makes
more sense.
However, I still cannot figure out how to extract the lat,lon pairs from the
LineCollection object. Searching on the web and based on Scott's suggestion
from another email, I see that in the past you could use a get_vertex()
option. However it appears to have been discontinued in mpl v 0.98.1.
I'm a relative newcomer to Python (less than 6 months) and even greener when
it comes to the inner workings of matplotlib. I'm sure I'm going to kick
myself when this is figured out...
-Patrick
On Sat, Aug 2, 2008 at 7:33 PM, Jeff Whitaker <[EMAIL PROTECTED]> wrote:
> Patrick Marsh wrote:
>
>> Thanks for the quick reply.
>>
>> I may not have been totally clear on what I'm trying to save (or I totally
>> misunderstood what you were trying to say - which is certainly possible).
>>
>> I'm not wanting to save the lat, lon pairs from the map projection. I'm
>> trying to save the lat, lon pairs of the contour. Using my original
>> example, if I'm plotting winds every 5 m/s, I'm wanting to pull off the lat,
>> lon pairs for the 5 m/s contours.
>>
>
> Patrick: I know - that's what I was trying to explain. You can get the
> x,y coordinates of the *contours* from the collections attribute of the
> ContourSet object returned by contour. Then you convert those x,y values
> back to lon,lat values using the Basemap instance.
>
> -Jeff
>
>>
>> I'll check out the website and see if I find anything there.
>>
>> -Patrick
>>
>>
>>
>> On Sat, Aug 2, 2008 at 6:13 PM, Jeff Whitaker <[EMAIL PROTECTED]
>> <mailto:[EMAIL PROTECTED]>> wrote:
>>
>> 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=/
>> <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> <mailto:Matplotlib-users@lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>> -- Jeffrey S. Whitaker Phone : (303)497-6313
>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
>> 325 Broadway Boulder, CO, USA 80305-3328
>>
>>
>>
>>
>
> --
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
> 325 Broadway Boulder, CO, USA 80305-3328
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
------------------------------
-------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
End of Matplotlib-users Digest, Vol 27, Issue 10
************************************************
-------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users