lundi 2 février 2015

Arcpy script not working


I am very new to developing tool boxes using arcpy on Arcgis 10.2. I have written the code down to the execution stage but I am hooked up there. Please Help. It is a basic code for band difference operation.


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


class Toolbox(object): def init(self): """Define the toolbox (the name of the toolbox is the name of the .pyt file).""" self.label = "Image Cal" self.alias = "My Calculator"



# List of tool classes associated with this toolbox
self.tools = [Tool]


class Tool(object): def init(self): """Define the tool (tool name is the name of the class).""" self.label = "Image Differencing" self.description = "This is a basic image calculator for differencing" self.canRunInBackground = True



def getParameterInfo(self):
"""Define parameter definitions"""
#first parameter
image1 = arcpy.Parameter (
displayName = "Input first Raster File",
name = "image1",
datatype = "Raster Layer",
parameterType = "Required",
direction = "Input"
)
image2 = arcpy.Parameter (
displayName = "Input second Raster File",
name = "image2",
datatype = "Raster Layer",
parameterType = "Required",
direction ="Input"
)
output = arcpy.Parameter (
displayName = "Output Raster",
name = "output",
datatype = "Raster Layer",
parameterType = "Required",
direction = "Output"
)
params = [image1, image2, output]
return params

def isLicensed(self):
"""Set whether tool is licensed to execute."""
arcpy.CheckOutExtension("Spatial")
return True

def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
image1 = params[0]
image2 = params[1]
output = params[2]


return

def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return

def execute(self, parameters, messages):
"""The source code of the tool."""
image1 = params[0].valueAsText
image2 = params[1].valueAsText
output = params[2].valueAsText

output_map= arcpy.sa.Minus( image1, image2)



return


Please do help me . you can also help by sending materials that you think might be of help to christad92@gmail.com.





Aucun commentaire:

Enregistrer un commentaire