Select Features by Location in ArcGIS Python API

1349
0
11-02-2018 10:56 AM
MarcHoogerwerf
Occasional Contributor

How can I implement a select Features by Location with the ArcGIS Python API?

I would like to select all features from a Point layer in a feature service that are within 0.5 meters from a feature in a Polyline layer in the same feature service. Both layers have the same spatial reference

Total number of point features is 35, total number of line features is 1

point_feature_layer.query(where='1=1')

returns 35 features

I've tried this:

# Create a Polyline first, because directly feeding cl_line.query(where='1=1').features[0].geometry into the spatial query on the points doesn't seem to work as a geometry_filter

from arcgis.geometry import Polyline

cl = Polyline(cl_line.query(where='1=1').features[0].geometry)

point_feature_layer.query(where='1=1',geometry_filter=cl, distance=0.5, units='esriSRUnit_Meter')

also returns 35 features, so the geometry_filter doesn't seem to work

The Javascript API documentation  suggested that with a distance parameter, the query would effectively select the points that Intersect a buffer of the polyline (buffered at the provided distance) so the default spatial relationship (intersects) would work.

Any ideas what I'm doing wrong here?

regards,

Marc

0 Kudos
0 Replies