使用Python fiona读取多边形

2024-10-04 01:37:21 发布

您现在位置:Python中文网/ 问答频道 /正文

现在,我可以使用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)   

输出如下:

http://i13.tietuku.com/65d7d9d6a423a5d3.png

但是,当shapefile由几个shapefile组成时:

^{pr2}$

http://i13.tietuku.com/a331edcbeec29d5e.png

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

我的问题

如何使用fiona来阅读并将其转换成几个菲奥纳多边形(在我的例子中,我想得到四个多边形)。然后,我可以用每个多边形做更多的运算。在


Tags: importcomhttpdatapng多边形shapefileshape