I'm using a bunch of tools in a stand alone script, and the near analysis tool does not work. Behavior is erratic, it runs from within ArcGIS only if the candidates are supplied as a string, not as a feature layer.import arcpy
pMXD = arcpy.mapping.MapDocument("C:\\Proj\\BBerry.mxd")
pDF = arcpy.mapping.ListDataFrames(pMXD, "Layers")[0]
## Candidates are point feature class
for fc in pDF:
if fc.name == "Candidates":
nearFeatures = fc
if fc.name == "tmp":
inFeatures = fc
## arcpy.Near_analysis(inFeatures, nearFeatures, "", "NO_LOCATION", "NO_ANGLE") ## Does not work!
arcpy.Near_analysis(inFeatures, "Candidates", "", "NO_LOCATION", "NO_ANGLE") ## Works
The goal is to add this function to a stand alone script, but it does not work as such no matter what. Stand alone script error message is: [INDENT]arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000732: Near Features: Dataset Candidates does not exist or is not supportedFailed to execute (Near).[/INDENT]Any suggestions are welcome.