[GIS] Setting linear units for Buffer distance from arcpy.GetParameterAsText()

arcpybuffer

I am trying to run a buffer tool as part of script that I will both use as a standalone script and import into ArcToolbox. I'm just wondering, if I use GetParameterAsText for the buffer distance, how do I set the linear units? E.g. I want it preset so they only have to type 300 and the script takes that to be meters? Here is what I have so far:

# Buffer the Thames feature class to create the Flood Risk Area
in_features = "Thames"
out_feature_class = "Flood_R_A"
# Run the Buffer Tool
arcpy.Buffer_analysis (in_features, out_feature_class, arcpy.GetParameterAsText(5),    "FULL", "ROUND", "ALL", "")

Best Answer

If you want the user to specify both a distance and units, as can be found in the Buffer tool (and most other tools that specify a distance), you can use the Linear Unit parameter. You can pass this whole parameter value to the tool

The distance passed to buffer can be numeric (in which case it's in the units of the feature class) or as numeric with units (meters, feet, degrees, etc).

Related Question