Select by Location geoprocessor not working

7277
5
01-17-2013 02:49 PM
MikeLouwrens
Occasional Contributor III
I am trying to use the 'Select Layer By Location' tool to select one point layer where it intersects with another point layer (so where one point is in the same location as a point in the second layer).  When I use the 'Select by Location' option from the Selection menu, this works correctly and selects 3802 records.

However when I try to use the 'Select Layer By Location' tool from ArcToolbox (or from the Python window, or using a python script directly) nothing is selected at all.  The tool says it completed successfully, but nothing is selected.

Here is what is in my Python window:
arcpy.SelectLayerByLocation_management("WSConNodes","INTERSECT","WSNode","", "NEW_SELECTION")


The input and selection layers are layers within my ArcMap.

Am I doing something wrong, or using the tool incorrectly?  I find it odd that it works from from the Selection menu dialogue, but not from the tool.

I'm running ArcMap 10.1 SP1.

Thanks,
Mike.
0 Kudos
5 Replies
MikeLouwrens
Occasional Contributor III
There appears to be a bit more to this issue.  I am working within a SDE version in ArcMap.  When I am in the version and run the Select Layer by Location tool, it doesn't work.  When I switch versions to sde.default the tool works.  After running the tool successfully, if I then try to switch back to my version I lose connection to those layers (I get the red exclamation mark next to my layers).

Does the Select layer tools not work in a version?

Cheers,
Mike.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Mike,

When you switch versions, are you performing the switch using the Table of Contents, or the 'Change Version' tool on the versioning toolbar?  If so, when you execute the Select Layer by Location tool, be sure you are using the drop-downs to select the layers from the table of contents, and you are not browsing for the feature class.

If you browse to the feature class, and the geodatabase connection properties are set to SDE.Default, this will be the version used to perform the selection.
0 Kudos
MikeLouwrens
Occasional Contributor III
When you switch versions, are you performing the switch using the Table of Contents, or the 'Change Version' tool on the versioning toolbar?
I've used both the Table of Contents and the Change Version button on the versioning toolbar, as well as using the Switch to New Version option when creating a new version from the versioning toolbar.
If so, when you execute the Select Layer by Location tool, be sure you are using the drop-downs to select the layers from the table of contents, and you are not browsing for the feature class.

If you browse to the feature class, and the geodatabase connection properties are set to SDE.Default, this will be the version used to perform the selection.
Yes, I was using only the drop-downs.  I believe the Select Layer By Location only uses layers, so browsing to the feature class work work anyway I think?

Cheers,
Mike.
0 Kudos
RyanClancy
Occasional Contributor
Hi Mike,

EDIT: Please disregard - it was user error on my part.

Did you ever solve this problem? I've encountered the same thing.

I have a point feature class and a polygon feature class and I'm using Select By Location to select the points that intersect the polygon. When I do the selection manually in ArcMap I get 20 features returned; when I do the same selection on the same data in Python via arcpy.SelectByLocation_management() I get 30 features returned. It's driving me bananas.

Ryan
0 Kudos
JanPindroch2
New Contributor

I had a similar problem today. Please check your ObjectID field if it is in the correct format....sometimes table join may screw this field in the Make Feature Layer process. Solution is to export data (using Select) to a feature class or shapefile and then use Make Feature Layer -> Select By Location -> Copy Features

0 Kudos