import arcpy
arcpy.env.OverwriteOutput = True
class Toolbox(object):
def __init__(self):
self.label = "StreamAnalysisTools"
self.alias = "DBGWetlandRestTools"
# List of tool classes associated with this toolbox
self.tools = [BufferExtract, SlopeAndStreamAnalysis]
class BufferExtract(object):
def __init__(self):
self.label = "1. Identify Study Area"
self.description = "This tool uses a Streamlines Shapefile to create a buffer of 50m, " \
"then uses buffer Features to Extract by Mask from DEM Raster. "
self.canRunInBackground = True
def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="Input Stream Features",
name="inStreams",
datatype=["DEFeatureClass", "DEShapefile", "DeFeatureDataset", "DELayer"],
parameterType="Required",
direction="Input"
)
param1 = arcpy.Parameter(
displayName="Input Buffer Distance",
name="bufferDist",
datatype="GPLinearUnit",
parameterType="Required",
direction="Input"
)
param1.value = 50
param2 = arcpy.Parameter(
displayName="Output Buffer Features",
name="outBuffer",
datatype="DEFeatureClass",
parameterType="Required",
direction="Output"
)
param3 = arcpy.Parameter(
displayName="Input DEM Raster",
name="inRaster",
datatype="DERasterDataset",
parameterType="Required",
direction="Input"
)
param4 = arcpy.Parameter(
displayName="Output Extracted Raster",
name="outRaster",
datatype="DERasterDataset",
parameterType="Required",
direction="Output"
)
params = [param0, param1, param2, param3, param4]
return params
def isLicensed(self):
if arcpy.CheckExtension("Spatial") == "Available":
return True
else:
return False
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
infeatures = parameters[0].valueAsText
bufferdist = parameters[1].valueAsText
outbuffer = parameters[2].valueAsText
inraster = parameters[3].valueAsText
outraster = parameters[4].valueAsText
mask = arcpy.Buffer_analysis(infeatures, bufferdist, outbuffer)
arcpy.gp.ExtractByMask_sa(inraster, mask, outraster)
return
Here is my code segment. I can't figure out what is going wrong, but when I run this, it fails at the buffer stage and returns ERROR 000728: Field (buffer output file) does not exist within table
Solved! Go to Solution.
I figured it out; buffer arguments were in the wrong order, and missing optional args. This fixed my problem.
param2 input dem raster
execute param2 outbuffer
are they in the correct order?
That's just a small mistake in transferring my code over. It's fixed in the current version, but still returning the error, even in the right order
Ian, maybe you can format the current version instead of using a screen grab, so people can comment with line number references
Alright, I changed that. Thanks for the tip! Hope this helps
buffer doesn't return anything, it just does it, so your 'mask' isn't there, you will have to use the results of buffer in your next step
ie outbuffer not mask)
arcpy.gp.ExtractByMask_sa(inraster, mask, outraster)
Right, but that's not the issue I'm having. It's the buffer step that's failing and returning the error. (Also, the process as written has worked in the past, when the buffer step was running).
I figured it out; buffer arguments were in the wrong order, and missing optional args. This fixed my problem.