cwarnold

SelectLayerByLocation 'WITHIN_A_DISTANCE' from point vs 'INTERSECT' point buffer

Discussion created by cwarnold on Jun 20, 2013
Latest reply on Jun 20, 2013 by dkwiens
I'm having trouble understanding the 'WITHIN_A_DISTANCE' option for arcpy.SelectLayerByLocation_management.

When I use arcpy.SelectLayerByLocation_management(lbTaCentroidsLayerName, 'WITHIN_A_DISTANCE', sitePntGeom, '25 Miles'), I get 815 points selected, but when I do arcpy.SelectLayerByLocation_management(lbTaCentroidsLayerName, 'INTERSECT', siteBufferFc) with a 25 miles buffer of the sitePntGeom, I get 1182 points selected.

Am I missing something obvious?

In [1]: import arcpy

In [3]: siteLon, siteLat = -122.276518, 47.191838

In [4]: sitePoint = arcpy.Point(siteLon, siteLat)

In [7]: sitePntGeom = arcpy.PointGeometry(sitePoint, wgs1984SpatialRef)

In [13]: lbTaCentroidsLayerName = 'centroidsFeatureLayer'

In [14]: arcpy.MakeFeatureLayer_management(centroidsFeatureClassName, lbTaCentroidsLayerName)
Out[14]: <Result 'centroidsFeatureLayer'>

In [15]: arcpy.SelectLayerByLocation_management(lbTaCentroidsLayerName, 'WITHIN_A_DISTANCE', sitePntGeom, '25 Miles')
Out[15]: <Result 'centroidsFeatureLayer'>

In [16]: int(arcpy.GetCount_management(lbTaCentroidsLayerName).getOutput(0))
Out[16]: 815

In [17]: siteBufferFc = 'in_memory/siteBuffer'

In [18]: arcpy.Buffer_analysis(sitePntGeom, siteBufferFc, '25 Miles')
Out[18]: <Result 'in_memory\\siteBuffer'>

In [19]: arcpy.SelectLayerByLocation_management(lbTaCentroidsLayerName, 'INTERSECT', siteBufferFc)
Out[19]: <Result 'centroidsFeatureLayer'>

In [20]: int(arcpy.GetCount_management(lbTaCentroidsLayerName).getOutput(0))
Out[20]: 1182

In [21]:

Outcomes