Hello, I have the following code that I am trying to make it work as a tool. If I pass the paths to variables it works perfectly but when I pass them as Tool Parameters when I don't have any result. I don't know what to correct, but there must be some problem with the combination of tool parameter name + "the file a create". I tried also to import it to variable outside tool and then import the variable for use in the tool but nothing changed. This is the code:
import arcpy import os from arcpy import env from arcpy.sa import * workspace = arcpy.GetParameterAsText(0) values = arcpy.GetParameterAsText(1) num_pnts = int(values) demodel = arcpy.GetParameterAsText(2) outReclass = Reclassify(demodel, "Value", RemapRange([[100,300,1],[301,500,0]]), "NODATA") outReclass.save(workspace + "rcls") n = 0 for i in range(num_pnts): n += 1 # Spatially Balanced Points arcpy.CreateSpatiallyBalancedPoints_ga(workspace + "rcls", 1, workspace + "point" + str(n)) inRaster = workspace + "rcls" inObserverFeatures = "point" + str(n) + ".shp" outViewshed = Viewshed(inRaster, inObserverFeatures) outViewshed.save(workspace + "view" + str(n))
Solved! Go to Solution.
Try using os.path.join to put together your file paths outViewshed.save(os.path.join(workspace, "view" + str(n)))