I am trying to do something similar to the plot_tissot.py example, but am 
having some problems.

  I would like to project a group of circles onto a map projection.  Below 
is the code I developed, which doesn't work because I get the error:
==========ERROR ====
  File "C:\Python25\Lib\site-packages\matplotlib\path.py", line 127, in 
__init__
    assert vertices.ndim == 2
AssertionError
==========

====CODE =========
m = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80, 
projection='cyl')
shp_info = m.readshapefile(r'C:\Documents and Settings\kpeters\My 
Documents\basemap-0.99\examples\tissot','tissot',drawbounds=True)
ax = plt.gca()
coords = 
[(116,45),(104,41),(98,37),(88,30),(78,25),(116,-45),(104,-41),(98,-37),(88,-30),(78,-25)]

for lon1,lat1 in coords:
    newverts   = []
    circle = Circle((lon1,lat1),radius=10, facecolor='green')
#    trans = circle.get_patch_transform()
    path = circle.get_path()
    #for jj in path.iter_segments():   #looks like the iterator is broken???
    for jj in path.vertices:
        verts1, verts2 = jj;
        newverts.append(m(verts1,verts2))
    print newverts
    p = PolyCollection(newverts, facecolor='green', zorder = 10)
    ax.add_collection(p)
==END CODE==

Is this a logical/best way to get circles properly projected, or is there a 
better way?

I looked at "transform_vector" but I'm not too sure what the uin and vin do. 
  Is there a transform in basemaps that could be passed to a path like in 
this thread: "Re: [Matplotlib-users] Drawing filled circles (discs)":
"circle = CirclePolygon((x1,y1), r, resolution)
trans = circle.get_patch_transform()
path = circle.get_path()
transpath = path.transformed(trans)"

It should be noted that I also tried:
===code dif===
for lon1,lat1 in coords:
    newverts   = []
    circle = Circle((lon1,lat1),radius=10, facecolor='green')
    path = circle.get_path()
    #for jj in path.iter_segments():   #looks like the iterator is broken???
    for jj in path.vertices:
        verts1, verts2 = jj;
        newverts.append(m(verts1,verts2))
    print newverts
#    newcircle = Circle(m(lon1,lat1),radius=10, facecolor='green')
    p = Polygon(newverts, facecolor='green', zorder = 10)
    ax.add_patch(p)
===========
but that doesn't seem to display anything (I suspect the right radius isn't 
being used).  Note, that the "newcircle" line that is commented out, puts 
circles on the map, they're just not transformed right.

Regards,
Kurt



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to