When I run >>>arcpy.Near_analysis("ACN_Select","Derden","150 Meters", "NO_LOCATION", "NO_ANGLE","PLANAR") in the python window in ArcMap 10.4, it returns the correct numbers in the field NEAR_DIST.
However, if I run the same in PyScripter:
import arcpy
arcpy.env.workspace = "C:\\Geoplay\\GLO\\Output.mdb"
arcpy.env.overwriteOutput = True
if arcpy.CheckExtension("Spatial") == "Available":
arcpy.AddMessage("Checking out Spatial")
arcpy.CheckOutExtension("Spatial")
else:
arcpy.AddError("Unable to get spatial analyst extension")
arcpy.AddMessage(arcpy.GetMessages(0))
sys.exit(0)
ACN_Select = "C:\\Geoplay\\GLO\\GLO.gdb\\ACN_Select"
Derden = "C:\\Geoplay\\GLO\\GLO.gdb\\Derden"
#Near Analysis
arcpy.Near_analysis(ACN_Select,Derden,"150 Meters","NO_LOCATION","NO_ANGLE","PLANAR")
print "Ready!"
All the NEAR_FID and NEAR_DIST are -1.
I tried creating layers and using those, but it didn't work. Also I tried setting the spatial ref with
spatRef = arcpy.Describe(ACN_in).spatialReference
but it did not change anything.
What am I missing?
Solved! Go to Solution.
And because the more recent FC has lines near ACN_Select, even the distance limiter now works. Thanks so much, Dan.
What if you strip the script way down and run it directly from the Python interpreter, not through PyScripter?
import arcpy
ACN_Select = "C:\\Geoplay\\GLO\\GLO.gdb\\ACN_Select"
Derden = "C:\\Geoplay\\GLO\\GLO.gdb\\Derden"
#Near Analysis
arcpy.Near_analysis(ACN_Select,Derden,"150 Meters","NO_LOCATION","NO_ANGLE","PLANAR")
Hi Joshua,
Thanks for responding. It took me a while to find Python command line and how to copy the text, but I did. It ran very quickly indeed, but with the same results. It does makes the fields NEAR_FID and NEAR_DIST, but fills them both with "-1".