我试图在地图上绘制插值天气数据,只在shapefile中包含的城镇范围内。以下是使用导入的shapefile在底图上绘制的未剪裁等高线: Contourf overlaid on Basemap with Shapefile
我尝试通过遍历等高线集合来剪裁等高线集合,如下所示:
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)
这显然将等高线限制为一个多边形,即一个城镇,如下所示: Contourf clipped to one ploygon
是否可以创建一个轮廓集合,然后我可以使用ax.add\集合(新系列)?大致如下:
for poly in patches:
for collection in cs.collections:
contour_collection.append(collection)
ax.add_collection(contour_collection)
或者我可以从Patchcollection创建一条路径,然后使用collection.set\u clip\u补丁(补丁)?你知道吗
根据swatchai的建议和Thomas Kühn之前的答案here,我设法解决了我的问题,见这里
通过执行以下操作:
相关问题 更多 >
编程相关推荐