使用python对NetCDF数据批处理并生成Geotiff文件

import arcpy  
from arcpy import env  
from arcpy.sa import *  
# Input data source  
arcpy.env.workspace = r'F:\seadata\2008peryear\core'#set the worksapce where NetCDF exist
arcpy.env.overwriteOutput = True  #If the file has already existed, it'll overwrite.
# Set output folder  
OutputFolder = r'F:\seadata\2008peryear\West_pacific\temperature\\'
# Loop through a list of files in the workspace  
NCfiles = arcpy.ListFiles("*.nc")  
for filename in NCfiles:  

    inNCfiles = arcpy.env.workspace + "/" + filename  
    fileroot = filename[11:17]  +'temp'
    TempLayerFile = "time"  
    outRaster = OutputFolder + "/" + fileroot  
    # Process: Make NetCDF Raster Layer  
    arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "temp", "lon", "lat", TempLayerFile, "", "", "BY_VALUE")
    # Process: Copy Raster  
    arcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "")
    print (filename+r"  has successfully been processed")
print r'all have successfully been processed'
print arcpy.GetMessages() 


版权声明:本文为weixin_46629224原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。