I am trying to use SearchCursor to loop through a feature class and create a Euclidean Distance raster dataset for every feature in that feature class. This ED raster dataset will be used for further analysis. However, I got this error message which I cannot solve. Can anyone explain or help please.

cursor = arcpy.SearchCursor(Tank_Location_Data)

for row in cursor:

    arcpy.gp.EucDistance_sa(row, "50", "1", "#")

Error message:

arcpy.gp.EucDistance_sa(row, "50", "1", "#")
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
  • What is your distance range?
    – fatih_dur
    Commented May 26, 2017 at 8:39

2 Answers 2


Firstly, I'd recommend using the search cursor in the data access module, arcpy.da.SearchCursor instead of the one you are using. It's much more efficient.

Secondly, the Euclidean distance tool doesn't work on individual rows of a dataset. You'll have to create a feature class for each record. You can do this by creating a temporary feature layer for each record. Try MakeFeatureLayer.

  • I already tried to MakeFeatureLayer for each record before the Euclidean Distance command. But I got this error message instead: arcpy.MakeFeatureLayer_management(row, "row_lyr") File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6043, in MakeFeatureLayer raise e RuntimeError: Object: Error in executing tool
    – Kim. A
    Commented May 26, 2017 at 5:43
  • Try running it again with just the shape. You can do that with the da.SearcgCursor
    – Fezter
    Commented May 26, 2017 at 5:49

I think you are using the incorrect modules in your code.

First off, you need to switch over to the Data Access module for cursors - arcpy.da.SearchCursor: http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm

You don't have to switch, but the da cursors perform better.

Second, the current method to call Euclidean Distance is to import arcpy.sa and then use this syntax:

EucDistance_sa (in_source_data, {maximum_distance}, {cell_size}, {out_direction_raster}, out_distance_raster)

You will also need to check out the spatial analyst extension in your script unless you are running from ArcMap with the extension already checked out.

Docs: https://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/euclidean-distance.htm

  • Please be aware the OP is asking about ArcGIS 10.2 but all of your documentation links to ArcGIS Pro.
    – Midavalo
    Commented May 26, 2017 at 5:19
  • Sorry, I should mention that I am using 10.2
    – Kim. A
    Commented May 26, 2017 at 5:46
  • @Midavalo - if you had checked, you would see that it is same details on the ArcMap page vs Pro desktop.arcgis.com/en/arcmap/latest/tools/… vs pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/…
    – jbalk
    Commented May 26, 2017 at 6:48
  • @jbalk That may be true for now, but ArcGIS Pro is a work in progress, and unlike previous versions of ArcMap, the help is updated with the application rather than separate documentation for each version so it has potential to change
    – Midavalo
    Commented May 26, 2017 at 13:05

Your Answer

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

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