我試圖僅在 shapefile 中包含的城鎮(zhèn)范圍內(nèi)在地圖上繪制插值天氣數(shù)據(jù)。以下是帶有導(dǎo)入 shapefile 的 Basemap 上未裁剪的輪廓: Contourf overlaid on Basemap with Shapefile我已經(jīng)嘗試通過迭代輪廓集合來裁剪輪廓集合,如下所示:m.readshapefile('data/grense', 'grense',zorder=10,linewidth=1, drawbounds=True)patches = []for info, shape in zip(m.grense_info, m.grense): patches.append( Polygon(np.array(shape), linestyle=':', fill=False) )for poly in patches: for collection in cs.collections: collection.set_clip_path(poly)這顯然將輪廓限制為一個多邊形,即一個城鎮(zhèn),如下所示: Contourf clipped to one ploygon是否可以創(chuàng)建一個輪廓集合的集合,然后我可以使用 ax.add_collection(new_contour_collection) 添加這些集合?類似的東西:for poly in patches: for collection in cs.collections: contour_collection.append(collection)ax.add_collection(contour_collection)或者我可以從 Patchcollection 創(chuàng)建單個路徑,然后使用 collection.set_clip_patch(patches) 剪輯每個輪廓集合?
添加回答
舉報
0/150
提交
取消