Revision: 5989 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5989&view=rev Author: jswhit Date: 2008-08-07 13:53:12 +0000 (Thu, 07 Aug 2008)
Log Message: ----------- use osgeo.ogr to read shapefile. Modified Paths: -------------- trunk/toolkits/basemap/examples/testgdal.py Modified: trunk/toolkits/basemap/examples/testgdal.py =================================================================== --- trunk/toolkits/basemap/examples/testgdal.py 2008-08-07 12:27:13 UTC (rev 5988) +++ trunk/toolkits/basemap/examples/testgdal.py 2008-08-07 13:53:12 UTC (rev 5989) @@ -39,7 +39,23 @@ m.drawparallels(np.linspace(llcrnrlat+0.1,urcrnrlat-0.1,5),labels=[1,0,0,0],fmt='%4.2f') # plot county boundaries from # http://edcftp.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz -shp_info = m.readshapefile('countyp020','counties',drawbounds=True,linewidth=1.0) +g = ogr.Open ("countyp020.shp") +L = g.GetLayer(0) +for feat in L: + field_count = L.GetLayerDefn().GetFieldCount() + geo = feat.GetGeometryRef() + if geo.GetGeometryCount()<2: + g1 = geo.GetGeometryRef( 0 ) + x =[g1.GetX(i) for i in range(g1.GetPointCount()) ] + y =[g1.GetY(i) for i in range(g1.GetPointCount()) ] + m.plot(x,y,'k') + for count in range( geo.GetGeometryCount()): + geom = geo.GetGeometryRef ( count ) + for cnt in range( geom.GetGeometryCount()): + g1 = geom.GetGeometryRef( cnt ) + x =[g1.GetX(i) for i in range(g1.GetPointCount()) ] + y =[g1.GetY(i) for i in range(g1.GetPointCount()) ] + m.plot(x,y,'k') # plot some cities. lons = [-105.22,-105.513,-105.316,-105.47]; lats = [39.76,39.801,39.633,39.41] names = ['Golden','Central City','Evergreen','Bailey'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- 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-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins