Inconsistent Select By Location behavior

538
3
05-15-2013 01:48 PM
GlennKammerer
New Contributor II
For the purposes of discussion, building a Topology is not an option, otherwise this exercise would be easy.

I am performing the same Select By Location two different ways.

The first method, let's say Method A, is performed manually, using the Select By Location icon in ArcMap. I am selecting line features from LayerL that intersect point features from LayerP. A review of the selection seems to indicate that results are accurate and expected.

The second method, let's say Method B, is performed via a Python script. Below is a code snippet

lyrL = arcpy.GetParameterAsText(0)
lyrP = arcpy.GetParameterAsText(1)
arcpy.SelectLayerByLocation_management(lyrL, "INTERSECT", lyrP, "", "NEW_SELECTION")


Method B does *NOT* return the same selection as Method A. The results of this selection are dubious, as many line features are not selected that do, in fact, intersect points, as well as many line features that are selected that do NOT intersect points.

I am thinking this might be a tolerance issue, but I can't find anything to support my theory. Anybody have an idea why this is, or has anybody experienced this before?
Tags (2)
0 Kudos
3 Replies
JamesCrandall
MVP Frequent Contributor
For the purposes of discussion, building a Topology is not an option, otherwise this exercise would be easy.

I am performing the same Select By Location two different ways.

The first method, let's say Method A, is performed manually, using the Select By Location icon in ArcMap. I am selecting line features from LayerL that intersect point features from LayerP. A review of the selection seems to indicate that results are accurate and expected.

The second method, let's say Method B, is performed via a Python script. Below is a code snippet

lyrL = arcpy.GetParameterAsText(0)
lyrP = arcpy.GetParameterAsText(1)
arcpy.SelectLayerByLocation_management(lyrL, "INTERSECT", lyrP, "", "NEW_SELECTION")


Method B does *NOT* return the same selection as Method A. The results of this selection are dubious, as many line features are not selected that do, in fact, intersect points, as well as many line features that are selected that do NOT intersect points.

I am thinking this might be a tolerance issue, but I can't find anything to support my theory. Anybody have an idea why this is, or has anybody experienced this before?


Are both lyrL and lyrP in the same spatial reference?  (just a hunch and something to dbl-chk)
0 Kudos
GlennKammerer
New Contributor II
The two feature classes in question are in the same feature dataset, so yes they are the same projection. And the data frame projection is the same as the feature dataset's, so I know it's not a projection issue.
0 Kudos
JamesCrandall
MVP Frequent Contributor
The two feature classes in question are in the same feature dataset, so yes they are the same projection. And the data frame projection is the same as the feature dataset's, so I know it's not a projection issue.


If you suspect the tolerance is the issue, perhaps you can attempt to select by location with a search distance parameter.  Something like (untested):


arcpy.SelectLayerByLocation_management(lyrL, "WITHIN_A_DISTANCE", lyrP, 2, "NEW_SELECTION")



I am a bit unsure of the linear unit you should set and the above is untested only pulled from the help:


http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000072000000

Sorry --- I just don't have specific experience with this scenario.
j
0 Kudos