""" Spatial Data Modeller for ESRI* ArcGIS 9.2 Copyright 2007 Gary L Raines, Reno, NV, USA: production and certification Don L Sawatzky, Spokane, WA, USA: Python software development the Gaussian which is given by: Gaussian(A(i), x) = exp( -((c(i) - x) ** 2 / (2*sigma(i)**2)) ) where c(i) and sigma(i) are the centre and width of the ith fuzzy set A(i), respectively. """ # Create the Geoprocessor object # Import system modules import sys, string, os, traceback #gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") import arcgisscripting gp = arcgisscripting.create() try: Evidence_Raster = gp.GetParameterAsText(0) #desc = gp.Describe(Evidence_Raster) #Evidence_Raster = desc.CatalogPath #gp.AddMessage(Evidence_Raster) MidPoint = gp.GetParameterAsText(1) #gp.AddMessage(Mean) Spread = gp.GetParameter(2) #gp.AddMessage(Spread) Output_Raster = gp.GetParameterAsText(3) if Output_Raster == "": Output_Raster = Evidence_Raster + "_Gauss" GP.SetParameterAsText(3,Output_Raster) #gp.AddMessage(Output_Raster) # Check out ArcGIS Spatial Analyst extension license gp.CheckOutExtension("Spatial") # Process gp.OverwriteOutput = 1 Evidence = gp.describe(Evidence_Raster).catalogpath InExpression = "EXP( %s * SQR( %s - %s ) )"%(-Spread, Evidence, MidPoint) gp.AddMessage(InExpression) # Process: MapAlgebraStatement gp.SingleOutputMapAlgebra_sa(InExpression,Output_Raster,"#") gp.SetParameterAsText(3,Output_Raster) except: # get the traceback object tb = sys.exc_info()[2] # tbinfo contains the line number that the code failed on and the code from that line tbinfo = traceback.format_tb(tb)[0] # concatenate information together concerning the error into a message string pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \ str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n" # generate a message string for any geoprocessing tool errors msgs = "gp ERRORS:\n" + gp.GetMessages(2) + "\n" gp.AddError(msgs) # return gp messages for use with a script tool gp.AddError(pymsg) # print messages for use in Python/PythonWin print pymsg print msgs raise