gis - Using Python fiona read polygons -
for now, can use fiona read 1 specific polygon , plot this:
## read shapefile import fiona import shapely shapely.geometry import shape c = fiona.open("xxx.shp") pol = c.next() geom = shape(pol['geometry']) poly_data = pol["geometry"]["coordinates"][0] poly = polygon(poly_data)
output this:
http://i13.tietuku.com/65d7d9d6a423a5d3.png
but when shapefile composed several shapefile this:
fig = plt.figure(figsize =(8,6)) ax = plt.gca() map = basemap(llcrnrlon=114.3,llcrnrlat=37.95,urcrnrlon=114.75,urcrnrlat=38.2) map.readshapefile("xxx",'xxx',zorder =1,) patches=[] cs=plt.cm.blues_r(np.arange(21)/21.) info, shape in zip(map.xxx_info, map.xxx): x,y=zip(*shape) patches.append( polygon(np.array(shape), true) ) # facecolor= '#6582b3' ax.add_collection(patchcollection(patches, facecolor= cs,edgecolor='none', linewidths=1.5, zorder=2,alpha = 0.8))
http://i13.tietuku.com/a331edcbeec29d5e.png
i can't use similar code above 4 polygon represent 4 different area.
my question
how use fiona read , transform several fiona.polygon(in example, want 4 polygon). , then, can use each polygon more operation.
Comments
Post a Comment