一、功能介绍
对栅格重采样工具的介绍,可以查看这篇博客:常用的Arcmap内置工具(一)
二、脚本代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import arcpy
from arcpy import env
import os
raster_path = arcpy.GetParameterAsText(0)
cell_size = arcpy.GetParameterAsText(1)
rs_type = arcpy.GetParameterAsText(2)
new_dir_name = arcpy.GetParameterAsText(3)
# Local variables:
def rs_batch(new_dir, new_prefix="rs_"):
env.workspace = raster_path
raster_list = arcpy.ListRasters("*", "tif")
for inraster in raster_list:
outraster = "\\" + new_dir + "\\" + new_prefix + inraster
arcpy.Resample_management(inraster, outraster, cell_size, rs_type)
arcpy.AddMessage("Step2:" + str(new_prefix) + inraster[:] + " has done.")
arcpy.SetProgressorPosition()
arcpy.AddMessage("Step2:Completed")
arcpy.ResetProgressor()
dir_name = new_dir_name
out_path = raster_path + "\\" + dir_name
os.makedirs(out_path)
arcpy.AddMessage("Step1:Creating new folder named " + str(dir_name))
arcpy.AddMessage("Step1:Completed")
rs_batch(dir_name)
三、工具参数
四、工具界面