#scrip
print"使用shp数据批量裁剪栅格数据并统计结果均值"
###########修改部分###########
ras_file= r"D:\python\nc\GLEAM\Transpiration_TIF_OUT" #待裁剪的原始栅格数据存储文件夹路径
suffix= 'tif' #待裁剪的原始栅格数据后缀
bvalue=-999.0 #待裁剪的原始栅格数据背景值
shp_file= r"D:\python\shp" #裁剪所需shp模板数据存储文件夹路径
ras_file_cut= r"D:\python\nc\GLEAM\Transpiration_YR_SWAT_mask" #裁剪后栅格数据结果存储文件夹路径
txtname=r"D:\python\nc\GLEAM\Transpiration_YR_SWAT_mask" #输出统计文本路径
#############################
#计算部分
import fenqutongji_arcpy
fenqutongji_arcpy.env.workspace=shp_file
shps=fenqutongji_arcpy.ListFeatureClasses()
fenqutongji_arcpy.env.workspace=ras_file
ras=fenqutongji_arcpy.ListRasters('*', suffix)
print "共有"+str(len(ras))+"个栅格数据"
#
print "Processing......"
for shin shps:
shtmp=sh.encode('cp936')
shpfile=shp_file+"\\"+shtmp
print "共有"+str(len(shps))+"个shp数据,正在处理第"+str(shps.index(sh)+1)+"个:"+shtmp
result=[]
for rsin ras:
rstmp=rs.encode('cp936')
outname=ras_file_cut+"\\"+rstmp[0:len(rstmp)-4]+shtmp[0:len(shtmp)-4]+".tif"
#arcpy.Clip_management(rstmp,"#",outname,shpfile,"#","ClippingGeometry")
fenqutongji_arcpy.Clip_management(rstmp, "#", outname, shpfile, str(bvalue), "ClippingGeometry")#忽略无效值
stats=fenqutongji_arcpy.GetRasterProperties_management(outname, "MEAN")
result.append(rstmp+' '+str(stats)+"\n")
# try:
# arcpy.Delete_management(outname,"")#注释则裁剪的栅格不删除,不注释删掉。
# except:
print(outname+'cannot delete')
file(txtname+"\\"+shtmp[0:len(shtmp)-4]+".txt",'w').writelines(result)
print "Finish!"
当然可以。先根据字符的长度,将字符分成N个组,每组一个字符。
然后根据电脑显示器的大小,创建一个图片框,高度和长度分别设置为电脑显示器的25%。
再将字符显示到图片框中,保存图片框的内容为图片文件即可。
几个需要注意的地方:1.phantomjs的路径要设置好,当然,用有头的浏览器也可以,如果你不嫌麻烦的话。
2本程序实现的是对本地的网页进行截图。