1

Im unable to get EucAllocation function working in ArcMap 10.5.1 or via Arcpy. I've used user guides for info but with no joy - http://desktop.arcgis.com/en/arcmap/10.5/tools/spatial-analyst-toolbox/euclidean-allocation.htm. I have noticed that using the "copy code snippet" from ArcMap is different to the format in above link.

code snippet (using defaults) = arcpy.gp.EucAllocation_sa(input,output, "", "", "5", "Value", "", "")

I have added the function where problematic part of the python script is. The code is generating a floodplain dataset from a DEM raster.

def create_floodplain(root_folder, in_gdb_name, working_gdb_name):

    # use output of get_raster function as input
    raster = get_raster(root_folder, in_gdb_name)

    working_gdb = os.path.join(root_folder, working_gdb_name)

    output_root = os.path.join(working_gdb, raster)
    #1 Raster Calc - convert DEM from floating point to int
    output_p1 = os.path.join(output_root + "_p1_rastercalc_TEST")

    print "Step 1. Running Raster Calculator...."
    rast_calc = Int(str(raster))
    # save output
    rast_calc.save(output_p1)
    print "Raster Calculator complete - %s" % (os.path.basename(output_p1))

    #2 Extract by Mask - create water boundary (ridgeline) raster
    input_p2 = output_p1
    mask_fc = os.path.join(working_gdb, "WATER_POLY_Clip16")
    output_p2 = os.path.join(output_root + "_p2_extractmask_TEST")

    print "Step 2. Running Extract By Mask...."
    ext_by_mask = ExtractByMask(input_p2, mask_fc)
    # save output
    ext_by_mask.save(output_p2)
    print "Extract By Mask complete - %s" % (os.path.basename(output_p2))

    #3 Euclidean Allocation - calculates, for each cell, the elevation value of the nearest ridgeline
    input_p3 = output_p2
    mask_fc = os.path.join(working_gdb, "WATER_POLY_Clip16")
    output_p3 = os.path.join(output_root + "_p3_euclideanallocation_TEST")

    print "Step 3. Running Euclidean Allocation...."
    euc_allocate = EucAllocation(input_p3, "", "", "5", "Value", "", "")
    # save output
    eucAllocate.save(output_p3)
    print "Euclidean Allocation complete - %s" % (os.path.basename(output_p3))

    #4 Raster Calc - create vertical buffer where 3 is the required buffer height (m)
    input_p4 = output_p3
    output_p4 = os.path.join(output_root + "_p4_rastercalc_TEST")

    print "Step 4. Running Raster Calculator...."
    rast_calc = raster >= (input_p4 + 3)
    # save output
    rast_calc.save(output_p4)
    print "Raster Calculator complete - %s" % (os.path.basename(output_p4))

The running of the EucAllocation (Step 3) in the above code is causing the issue as it is resulting in the below error:

ExecuteError: ERROR 999999: Error executing function. A column was specified that does not exist. A column was specified that does not exist. The table was not found. [VAT_EucAllo_Suir1] No spatial reference exists. ERROR 010296: Error in writing raster C:\Users\XXX\AppData\Local\Temp\t_t83.tif. Distance mapping is failed. ERROR 010067: Error in executing grid expression. Failed to execute(EucAllocation).

1 Answer 1

1

After Step 2, run arcpy.BuildRasterAttributeTable_management(output_p2, 'Overwrite').

The attribute table isn't necessarily created automatically after ExtractByMask or any other process. I've never figured out the rules for when it is/isn't, but I find it good practice to go ahead and build it after many operations.

See http://desktop.arcgis.com/en/arcmap/10.5/tools/data-management-toolbox/build-raster-attribute-table.htm

1
  • Adding that arcpy function into code solved my issue. Thank you very much @Tom.
    – Rob
    Jun 7, 2018 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.