AnsweredAssumed Answered

Model builder and exception in arcpy script

Question asked by ivandorte on Jan 20, 2016
Latest reply on Jan 20, 2016 by lsturtevant

I'm trying to finish my model... but I have a problem. I need to introduce in my model a script that choise between kriging and IDW/spline interpolation. Kriging is the default method used in my model, but If kriging return an error then I want to run IDW interpolation and pass the result to another tool.

My model runs fine with kriging interpolation, raster was produced and the tool "extract values to points" run successfully.

But if the kriging method return an error and the script calculate IDW/Spline, raster output was produced but extract values to point was unable to run successfully. And I receive this statement: "All the inputs are not current"

 

Immagine.pngThe error:

 

Parameters settings:

 

 

The script:

 

import arcpy

import sys

from arcpy.sa import *

 

limiti = arcpy.GetParameterAsText(0)

 

arcpy.env.mask = limiti

arcpy.env.extent = limiti

 

errors = 0

 

inFC = arcpy.GetParameterAsText(1)

campo = arcpy.GetParameterAsText(2)

outRaster = arcpy.GetParameterAsText(3)

 

 

cellSize = 1000

 

Modello = "Spherical"

 

try: 

    arcpy.Kriging_3d(inFC, campo, outRaster, Modello,cellSize, "", "") 

except Exception:

    e = sys.exc_info()[1]

    print(e.args[0])

    arcpy.AddError(e.args[0])

    errors += 1

 

if errors > 0:

    arcpy.Spline_3d(inFC, campo, outRaster,cellSize, "TENSION", "","")

Outcomes