本文主要是介绍[ArcPy] 批量波段合成 Landsat8数据为例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
# -*- encoding:utf-8 -*-
import os
import sys
import arcpy
from arcpy import envworkspace = r'F:\landsat8' #文件
outpath = r'D:\layer_stacking' #结果存放# function:按顺序拼接字符串
def getInputParam(files):ret = ""for i in range(1,12): #11个波段judge = "B%d.TIF" % ifor file in files: #拼接1-11波段if judge in file:print fileret = ret + file + ";"files.remove(file) #去除breakfor file in files: # 拼接其他的print fileret = ret + file + ";"ret = ret[:-1] #去除最后的;return retdirs = os.listdir(workspace)
for dir in dirs:files_path = os.path.join(workspace,dir)files = os.listdir(files_path)input_param = getInputParam(files)env.workspace = files_pathoutpath = os.path.join(outpath,dir + ".tif")arcpy.CompositeBands_management(input_param, outpath)
这篇关于[ArcPy] 批量波段合成 Landsat8数据为例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!