From: <js...@us...> - 2007-12-07 00:01:50
|
Revision: 4661 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4661&view=rev Author: jswhit Date: 2007-12-06 16:01:46 -0800 (Thu, 06 Dec 2007) Log Message: ----------- fixed so it really should work now with MultiPoint shape files (although I haven't found one to test with). Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-06 23:32:15 UTC (rev 4660) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-07 00:01:46 UTC (rev 4661) @@ -1380,16 +1380,23 @@ in map projection coordinates. You can convert the shapefile to geographic coordinates using the shpproj utility from the shapelib tools (http://shapelib.maptools.org/shapelib-tools.html)""") - if info[1] in [1,8]: # a Point or Multi-Point file. - coords = [shp.read_object(i).vertices()[0] - for i in range(shp.info()[0])] - attributes = [dbf.read_record(i) - for i in range(shp.info()[0])] - lons, lats = zip(*coords) - if max(lons) > 721. or min(lons) < -721. or max(lats) > 91. or min(lats) < -91: - raise ValueError,msg - x,y = self(lons, lats) - self.__dict__[name]=zip(x,y) + if info[1] in [1,8]: # a Point or MultiPoint file. + coords = [] + nelements = shp.info()[0] + for nelement in range(nelements): + shp_object = shp.read_object(nelement) + verts = shp_object.vertices() + lons, lats = zip(*verts) + if max(lons) > 721. or min(lons) < -721. or max(lats) > 91. or min(lats) < -91: + raise ValueError,msg + if len(verts) > 1: # MultiPoint + x,y = self(lons, lats) + coords.append(zip(x,y)) + else: # single Point + x,y = self(lons[0], lats[0]) + coords.append((x,y)) + attributes = [dbf.read_record(i) for i in range(nelements)] + self.__dict__[name]=coords self.__dict__[name+'_info']=attributes else: # a Polyline or Polygon file. shpsegs = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |