Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python菲奥娜读取多边形_Python_Gis_Shapefile_Shapely_Fiona - Fatal编程技术网

使用Python菲奥娜读取多边形

使用Python菲奥娜读取多边形,python,gis,shapefile,shapely,fiona,Python,Gis,Shapefile,Shapely,Fiona,现在,我可以使用fiona读取一个特定多边形,并按如下方式绘制: ## read the shapefile import fiona import shapely from shapely.geometry import shape c = fiona.open("xxx.shp") pol = c.next() geom = shape(pol['geometry']) poly_data = pol["geometry"]["coordinates"][0] poly = Polygon(

现在,我可以使用fiona读取一个特定多边形,并按如下方式绘制:

## read the shapefile
import fiona
import shapely
from 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)   
输出如下:

但是,当形状文件由以下几个形状文件组成时:

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.)
for 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))


我不能用上面类似的代码得到4个多边形代表4个不同的区域

我的问题
如何使用菲奥娜来读取并将其转换成多个菲奥娜多边形(在我的例子中,我想得到四个多边形)。然后,我可以使用每个多边形来执行更多操作。

“我无法使用上面的类似代码来获取表示4个不同区域的4个多边形。”--为什么不,会发生什么?请尝试多次调用“c”上的“next()”以迭代内容。或者尝试使用“for”循环来迭代“c”的内容。“我无法使用上面类似的代码来获得表示4个不同区域的4个多边形。”--为什么不,会发生什么?尝试多次调用“c”上的“next()”来迭代内容。或者尝试使用“for”循环来迭代“c”的内容。