基于Python(Arcpy)批量对遥感影像(HDF)求年平均值,结果为TIF图

主体函数:

# coding=utf-8
import time
start = time.clock()
import arcpy
import os
from arcpy.sa import *
# 掩膜提取研究区
def areaByMask(workSpace_hdf,workSpace_tif,mask_path,researchArea_path):
    arcpy.env.workspace = workSpace_hdf
    arcpy.env.overwriteOutput = True

    # 将HDF转成TIF
    print "正在进行将HDF转成TIF"
    ls_hdf = arcpy.ListRasters("*","hdf")
    if len(ls_hdf)<46:
        print "影像少于46个,无法计算"
        return
    for hdf in ls_hdf:
        tif_path = workSpace_tif+"/"+hdf[20:23]+"_hdf.tif"
        arcpy.ExtractSubDataset_management(hdf,tif_path)
        # 进行定义投影
        arcpy.DefineProjection_management(tif_path,"F:/LAI_CHINA/WGS 1984.prj")

    arcpy.env.workspace = workSpace_tif
    arcpy.env.overwriteOutput = True
    ls_tif = arcpy.ListRasters("*","tif")
    if len(ls_tif)<46:
        return
    i =

你可能感兴趣的:(Python,ARCPY,python,hdf)