Running Python script that is exported from model builder

Discussion created by myswat on Mar 6, 2014
Latest reply on Mar 6, 2014 by EKrause-esristaff
So I???ve put up a simple model involving Kernel interpolation with barrier tool in ArcMap model builder and exported to Python script. (since the script is fairly short, I???ve pasted it down below.)

I feel the script is fine. But after I added to my toolbox in ArcMap and try to run it, some error pops up.

After a whole morning???s debugging, alas, I???ve finally managed to get ArcMap to crash every time I run my script...

I am guessing the problem is with the parameters I added to the script.

Could anyone explain a bit on how one should make sure a python script could be run from the toolbox and all parameters are called correctly.

More specifically: when I add parameters in ArcMap, given the python script that I already have, what display names should I put down for the parameters so that the software recognizes.

Any input is welcome and appreciated.

Here we go:

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Created on: 2014-03-06 11:38:22.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: my <Z_value_field> <Input_features> <Output_cell_size> <Output_raster> <Input_absolute_barrier_features>
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Check out any necessary licenses

# Set Geoprocessing environments
arcpy.env.outputCoordinateSystem = "PROJCS['NAD_1983_StatePlane_Massachusetts_Mainland_FIPS_2001',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',200000.0],PARAMETER['False_Northing',750000.0],PARAMETER['Central_Meridian',-71.5],PARAMETER['Standard_Parallel_1',41.71666666666667],PARAMETER['Standard_Parallel_2',42.68333333333333],PARAMETER['Latitude_Of_Origin',41.0],UNIT['Meter',1.0]]"
arcpy.env.extent = "228036.127400003 885223.3233 272353.924400003 922000.4802"
arcpy.env.mask = "presentaiton_area_mask"

# Script arguments
Z_value_field = arcpy.GetParameterAsText(0)

Input_features = arcpy.GetParameterAsText(1)

Output_cell_size = arcpy.GetParameterAsText(2)
if Output_cell_size == '#' or not Output_cell_size:
    Output_cell_size = "147.1086276" # provide a default value if unspecified

Output_raster = arcpy.GetParameterAsText(3)

Input_absolute_barrier_features = arcpy.GetParameterAsText(4)

# Local variables:
Output_geostatistical_layer = Input_features

# Process: Kernel Interpolation With Barriers
arcpy.KernelInterpolationWithBarriers_ga(Input_features, Z_value_field, Output_geostatistical_layer, Output_raster, Output_cell_size, Input_absolute_barrier_features, "POLYNOMIAL5", "2000", "1", "50", "PREDICTION")