I am trying to determine the relative drainage area of two type of distinct wetlands. I am using these individual wetlands as the pour points for the watershed tool in ArcMap's spatial analyst toolbox. I need to perform this same analysis in multiple study areas, and tried to automate the process. The general process uses spatial analyst tools: Reclassify > RegionGroup > Watershed

The final code will loop through a number of polygons and clip each layer to the outline of the polygon. For now I am just putting together the general spatial analyst workflow.

 path =  r'G:\Flow_Adjacency_Analysis\TEST.gdb\Wetlands'
_Grouped_name = path+'_Grouped'
Grouped_wetlands = arcpy.sa.RegionGroup('Reclassified_wetlands', 'EIGHT', 'WITHIN', 'NO_LINK')
Grouped_wetlands.save(_Grouped_name)

out_watershed = arcpy.sa.Watershed("Flow_dir", _Grouped_name)
out_path = path + '_Watershed'
out_watershed.save(out_path)

When these operations were performed manually there was no attribute table for the watershed raster. This problem was solved using either 'Copy_Raster' or 'BuildAttributeTable' with no issue. Neither one of these approaches works in the python code however. Copy Raster produces Error 999999:

arcpy.management.CopyRaster(out_path,'wetland_DA' , None, None, 65535, "NONE", "NONE", "32_BIT_SIGNED", "NONE", "NONE", "GRID", "NONE")



C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in 
CopyRaster(in_raster, out_rasterdataset, config_keyword, background_value, 
nodata_value, onebit_to_eightbit, colormap_to_RGB, pixel_type, 
scale_pixel_value, RGB_to_Colormap, format, transform)

14292         return retval
14293     except Exception as e:
> 14294         raise e
14295 
14296 @gptooldoc('CreateRandomRaster_management', None)

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in 
CopyRaster(in_raster, out_rasterdataset, config_keyword, background_value, 
nodata_value, onebit_to_eightbit, colormap_to_RGB, pixel_type, 
scale_pixel_value, RGB_to_Colormap, format, transform)

14289     from arcpy.arcobjects.arcobjectconversion import 
convertArcObjectToPythonObject

14290     try:
> 14291         retval = convertArcObjectToPythonObject(gp.CopyRaster_management(*gp_fixargs((in_raster, 
out_rasterdataset, config_keyword, background_value, nodata_value, 
onebit_to_eightbit, colormap_to_RGB, pixel_type, scale_pixel_value, 
RGB_to_Colormap, format, transform), True)))

14292         return retval
14293     except Exception as e:

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py in 
<lambda>(*args)

494         val = getattr(self._gp, attr)
495         if callable(val):
--> 496             return lambda *args: val(*gp_fixargs(args, True))
497         else:
498             return convertArcObjectToPythonObject(val)


ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. 
Please refer to the error help for potential solutions, or contact Esri         
Technical Support http://esriurl.com/support.
General function failure [wetland_DA]
The table was not found.
The table was not found. [fras_blk_Watersh_Flow1]
No spatial reference exists.
The table was not found. [wetland_DA]
Failed to execute (CopyRaster).

And Build Raster Attribute Table produces Error 000049:

arcpy.management.BuildRasterAttributeTable(out_path, "NONE")

ExecuteError: ERROR 000049: Failed to build attribute table
Failed to execute (BuildRasterAttributeTable).

Trying to access the raster layer directly using either a Search Cursor or a making a table from the raster using 'arcpy.MakeTableView_management' produces Error 000229:

tbl = arcpy.MakeTableView_management(out_watershed, 'test_tbl')    

ExecuteError: ERROR 000229: Cannot open G:\Flow_Adjacency_Analysis_\TEST.gdb\Wetlands_Watershed'
Failed to execute (MakeTableView).

I am trying to troubleshoot these errors to try and fix this code. Given the number of different errors I don't know where to start. The raster exists in the gdb and doesn't have any existing locks. The process works without any errors when I do it manually in ArcGIS Pro.

A couple of things to note.

You have tagged your question as a 10.1 question but have used the syntax structure of the Copy Raster tool from a modern version but then go on to talk about ArcGIS Pro. So it is unclear what you are using.

If you are using 10.1 then suggest you read the help file here as you have too many parameters.

Assuming you are using 10.6 then the syntax for parameter 2 is a raster dataset. You have provided nothing more than a string 'wetland_DA'. This is not a full path to a raster nor is there any evidence you have set the workspace environment setting.

Suggest you look there first and if that does not help then clean up your question.

  • Thanks for the suggestions Hornbydd. I did leave out the potion of code where I set the workspace env. arcpy.env.overwriteOutput = True arcpy.env.workspace = r'G:\Flow_Adjacency_Analysis\TEST.gdb so the string 'wetland_DA' was a valid out raster name. I have updated the tags - as I am not using 10.1 but ArcGIS Pro 2.2.4. – Alumes Nov 7 at 15:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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