"""、
取多波段的值
转ASC
多值到点
"""
在这里插入代码片
import os.path
import shutil
import arcpy
from arcpy import env
from arcpy.conversion import RasterToASCII
from shutil import copyfile
from arcpy.sa import ExtractMultiValuesToPoints
arcpy.CheckOutExtension("spatial")
arcpy.env.workspace = 'D:\\xh'
Ratif = arcpy.ListRasters("*", "tif")
for Ratif1 in Ratif:
arcpy.env.workspace = 'D:\\xh'
mypath="d:\\test\\"+Ratif1[:-4]+"\\"
ascpath="d:\\test\\"+Ratif1[:-4]+"asc"+"\\"
os.mkdir(mypath)
os.mkdir(ascpath)
source = "D:\\Climate_Data_Asc\\wd_Distri\\"
filenames = os.listdir(source)
for filename in filenames:
shutil.copyfile(source+filename, mypath+filename)
shutil.copyfile(source + filename, ascpath + filename)
for i in range(1,20):
Name_GPP1 = Ratif1[:-4] +"Band_"+repr(i)+ ".tif"
outGpp = arcpy.MakeRasterLayer_management(Ratif1, Name_GPP1, "#", Ratif1, i)
Out_GPP2 = mypath + Name_GPP1
arcpy.Int_3d(outGpp, Out_GPP2)
outASC = ascpath + "Bio" + Name_GPP1[-6:-4] + ".asc"
RasterToASCII(outGpp, outASC)
env.workspace = ascpath
filenames = os.listdir(ascpath)
for filename in filenames:
if os.path.splitext(filename)[1] == '.asc':
arcpy.CheckOutExtension("Spatial")
inPointFeatures = ascpath + "white-lipped_deer.shp"
inRasterList=filename
ExtractMultiValuesToPoints(inPointFeatures, inRasterList, "BILINEAR")
print ("All have done!")