I have created a script (see below) that works ok but only in case if all parameters are required inputs. Quite simple, Roads(line) and Tracts(polygon) feature classes , first buffer Roads and then clip to Tracts. There are more feature classes in Zion.gdb but I am just doing a test script to figure out optional input parameters.
What I need is that user should be able to select the layer they want to buffer, the layer they want to clip, the output location/name of the clip, and the buffer distance. All of it has to be optional. The problem is when I set for example Tracts and Tracts_Clip feature classes to optional in Script Parameters and do not apply them in script execution because I want only Roads buffer, the script does not work. Disregard red x symbol, I shortened the path.
Any help would be much appreciated!!!
import arcpy
import arcpy
from arcpy import env
env.workspace = "C:/data/Zion.gdb"
env.overwriteOutput = True
Roads = arcpy.GetParameterAsText(0)
if Roads == '
Roads = arcpy.GetParameterAsText(0)
Tracts = arcpy.GetParameterAsText(1)
if Tracts == '
Tracts = arcpy.GetParameterAsText(1)
Tracts_Clip = arcpy.GetParameterAsText(2)
if Tracts_Clip == '
Tracts_Clip = arcpy.GetParameterAsText(2)
Buffer_Distance = arcpy.GetParameterAsText(3)
if Buffer_Distance == '
Buffer_Distance = arcpy.GetParameterAsText(3)
Tracts_Clip = arcpy.GetParameterAsText(2)
Buffer_Distance = arcpy.GetParameterAsText(3)
Roads_Buffer = "Roads_Buffer"
arcpy.Buffer_analysis(Roads, Roads_Buffer, Buffer_Distance,"FULL", "ROUND", "ALL", "", "")
arcpy.Clip_analysis(Tracts, Roads_Buffer, Tracts_Clip, "")