<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Select Features by Location in ArcGIS Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/select-features-by-location-in-arcgis-python-api/m-p/850165#M3805</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I implement a select Features by Location with the ArcGIS Python API?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Total number of point features is 35, total number of line features is 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;point_feature_layer.query(where='1=1')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;returns 35 features&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this:&lt;/P&gt;&lt;P&gt;# Create a Polyline first, because directly feeding&amp;nbsp;&lt;SPAN&gt;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&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;from arcgis.geometry import Polyline&lt;/P&gt;&lt;P&gt;cl = Polyline(cl_line.query(where='1=1').features[0].geometry)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;point_feature_layer.query(where='1=1',geometry_filter=cl, distance=0.5, units='esriSRUnit_Meter')&lt;/P&gt;&lt;P&gt;also returns 35 features, so the geometry_filter doesn't seem to work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Javascript API documentation&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what I'm doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Nov 2018 17:56:05 GMT</pubDate>
    <dc:creator>MarcHoogerwerf</dc:creator>
    <dc:date>2018-11-02T17:56:05Z</dc:date>
    <item>
      <title>Select Features by Location in ArcGIS Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/select-features-by-location-in-arcgis-python-api/m-p/850165#M3805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can I implement a select Features by Location with the ArcGIS Python API?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Total number of point features is 35, total number of line features is 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;point_feature_layer.query(where='1=1')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;returns 35 features&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this:&lt;/P&gt;&lt;P&gt;# Create a Polyline first, because directly feeding&amp;nbsp;&lt;SPAN&gt;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&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;from arcgis.geometry import Polyline&lt;/P&gt;&lt;P&gt;cl = Polyline(cl_line.query(where='1=1').features[0].geometry)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;point_feature_layer.query(where='1=1',geometry_filter=cl, distance=0.5, units='esriSRUnit_Meter')&lt;/P&gt;&lt;P&gt;also returns 35 features, so the geometry_filter doesn't seem to work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Javascript API documentation&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what I'm doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2018 17:56:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/select-features-by-location-in-arcgis-python-api/m-p/850165#M3805</guid>
      <dc:creator>MarcHoogerwerf</dc:creator>
      <dc:date>2018-11-02T17:56:05Z</dc:date>
    </item>
  </channel>
</rss>

