#使用shp資料批量裁剪柵格資料並統計均值
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")
# arcpy.delete_management(outname,"")#注釋則裁剪的柵格不刪除,不注釋刪掉。
# except:
print(outname+'cannot delete')
file(txtname+"\"+shtmp[0:len(shtmp)-4]+".txt",『w』).writelines(result)
print "finish!"計均值這裡寫自定義目錄標題)
ArcGIS批量裁剪柵格資料
arcpy批量計算柵格資料平均值 arcgis批量裁剪柵格資料 arcpy批量柵格重取樣 arcpy批量裁剪柵格資料 idl多程序批處理遙感資料 arcpy批量拼接柵格資料 做遙感資料處理,經常會用到,長時間序列的某些影像。這些資料的特點是 相同區域,不同時間,要使用同乙個shp來進行柵格裁剪。關於...
arcgis批量處理柵格資料
在arcgis中,柵格資料的處理比較繁瑣,自帶的工具箱中可做的統計有限。本次借助arcpy對柵格資料進行批量處理,並可以實現柵格到numpy陣列的轉變,從而可以對其進行中位數 平均數 眾數等更多元化的統計分析。選用的arcgis版本為10.2,python版本為2.7,還需要numpy arcpy等...
使用向量面裁剪柵格資料的對齊問題
最近湊巧有幾個比較多的柵格裁剪問題,整理如下 我們只有由於柵格與向量資料的儲存模型不相同,這就導致柵格資料的像元無法與向量資料的點等同,從而導致裁切後的對齊問題,放大資料我們就能發現,如下圖可以說明 其中黑白色為柵格資料,每個正方形代表乙個像元,紅色區域為向量面資料。我們按照預設設定執行 raste...