1

今のところ、fionaを使用して 1 つの特定のポリゴンを読み取り、次のようにプロット できます。

## 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

しかし、シェープファイルが次のように複数のシェープファイルで構成されている場合:

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

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

上記の同様のコードを使用して、4 つの異なる領域を表す 4 つのポリゴンを取得することはできません。

私の質問

fiona を使用して読み取り、複数の fiona.polygon に変換する方法 (私の例では、4 つのポリゴンを取得したい)。そして、各ポリゴンを使用してさらに多くの操作を行うことができます。

4

0 に答える 0