- 积分
- 119
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-6
- 最后登录
- 1970-1-1

|
发表于 2019-6-28 23:33:55
|
显示全部楼层
请问为什么我出现如下错误呢?
local variable 'clip1' referenced before assignment
代码如下:
fig = plt.figure(figsize=[10, 8])
# Set projection and plot the main figure
ax = plt.axes(projection=ccrs.LambertConformal(central_latitude=30.5,
central_longitude=118.5))
border = r"d:\forcast\shp\宣城边界.shp"
shape_feature = cfeature.ShapelyFeature(Reader(border).geometries(),ccrs.PlateCarree(),edgecolor='k',facecolor='none')
ax.add_feature(shape_feature)
ax.gridlines(linestyle='--')
# Set figure extent
ax.set_extent([117.8, 119.8, 29.8, 31.5])
#set colormap
levels=[0,0.1,10,25,50,100,250,500]#雨量间隔
colors=['#FFFFFF','#A5F38D','#3DB93F','#63B8F9','#0000FE','#F305EE','#810040']#雨量标准色标
cf=plt.contourf(lons,lats,f,15, levels=levels, colors=colors,transform=ccrs.PlateCarree())
plt.colorbar()
shijian=str(d1.year)+'年'+str(d1.month)+'月'+str(d1.day)+'日'+str(d1.hour)+'时'+'--'+str(d2.year)+'年'+str(d2.month)+'月'+str(d2.day)+'日'+str(d2.hour)+'时'+'雨量预报'
plt.title(shijian,fontsize=20,color='blue')
d1=d2
clip2=maskout.shp2clip(cf,ax,'d:\\forcast\\shp\\xc.shp',[341881]) #白化
plt.savefig(outfile)
plt.show() |
|