Using a python script, I am running a near analysis from a small point feature class as the "in_features" to some lines (the "near_features"), a large (many thousands of records) feature layer which has a selection on it so that there are only a few records that are selected.
This script has worked for several years, but it has now stopped working, resulting in an "ERROR 999999". However, I can work around this if I add another line of code to my python script so that the small subset of selected features for my "near_features" feature layer is copied (using CopyFeatures) to a file geodatabase as a polyline feature class, and then use that feature class as the "near_features".
The help for Near Analysis says, for the near_features, that they can be "One or more feature layers or feature classes containing near feature candidates."
So why is it that this script has worked just fine using the same datasets before, but now I must save my feature layer as a feature class for it to work?
Solved! Go to Solution.
I can't test anything because this tool requires Advanced licensing, but two things jump out:
1.) Have you upgraded since the script last worked?
2.) The help says that the input features can have a selection, but says nothing about the near features having a selection. When you export your layer to the feature class, it has no selection. Have you tried running your script on a feature layer with no selection? (I don't know why this would be the case, but it seems to fit your situation)
I can't test anything because this tool requires Advanced licensing, but two things jump out:
1.) Have you upgraded since the script last worked?
2.) The help says that the input features can have a selection, but says nothing about the near features having a selection. When you export your layer to the feature class, it has no selection. Have you tried running your script on a feature layer with no selection? (I don't know why this would be the case, but it seems to fit your situation)
Thanks for the suggestion Darren. I tested on a feature layer with no selection. The Near analysis runs just fine as long as there is no selection on the near_features.
I am running this on ArcGIS 10.2, and the last time I ran this script was almost certainly on ArcGIS 10.1.
So, I happen to have access to 10.1 and I ran my script there. On ArcGIS 10.1, the Near analysis runs just fine on a feature layer with a selection on it.
So the result of all this: In ArcGIS 10.2, Near analysis will produce an "ERROR 999999" when run using the "near-features" as a feature layer with a selection on it. And ArcGIS 10.1 has no problem with a selection on the feature layer.