一、功能介绍功能介绍
对乘工具的介绍,可以查看这篇博客:常用的Arcmap内置工具(一)
在这里插入图片描述

二、脚本代码

#!/usr/bin/python
# -*- coding: UTF-8 -*-


import arcpy
from arcpy import env
from arcpy.sa import *


raster_path = arcpy.GetParameterAsText(0)
scale_factor = arcpy.GetParameterAsText(1)
new_dir_name = arcpy.GetParameterAsText(2)


def multiply_batch(new_dir_name, new_prefix = "multi_"):
    env.workspace = raster_path
    raster_list = arcpy.ListRasters("*", "tif")
    for inraster in raster_list:
        outraster = "\\" + new_dir_name + "\\" + new_prefix + inraster
        arcpy.gp.Times_sa(inraster, scale_factor, outraster)
        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")
if arcpy.CheckExtension("Spatial") == "Available":
    multiply_batch(dir_name)
else:
    arcpy.AddMessage("Error!!! Spatial Analyst is unavailable")

三、工具参数
3-1
3-2

四、工具界面4-1

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐