10.7 Custom Toolbox; buffer tool error 000728: field <output features> does not exist within the table

1027
7
Jump to solution
11-10-2019 10:22 PM
IanBoddie
New Contributor II
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

0 Kudos
1 Solution

Accepted Solutions
IanBoddie
New Contributor II

I figured it out; buffer arguments were in the wrong order, and missing optional args. This fixed my problem.

View solution in original post

0 Kudos
7 Replies
DanPatterson_Retired
MVP Esteemed Contributor

param2 input dem raster

execute param2 outbuffer

are they in the correct order?

0 Kudos
IanBoddie
New Contributor II

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

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Ian, maybe you can format the current version instead of using a screen grab, so people can comment with line number references

/blogs/dan_patterson/2016/08/14/script-formatting 

0 Kudos
IanBoddie
New Contributor II

Alright, I changed that. Thanks for the tip! Hope this helps

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Buffer—Help | ArcGIS Desktop 

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)

0 Kudos
IanBoddie
New Contributor II

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).

0 Kudos
IanBoddie
New Contributor II

I figured it out; buffer arguments were in the wrong order, and missing optional args. This fixed my problem.

0 Kudos