<?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 Re: select layer by geometry in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176698#M8177</link>
    <description>&lt;P&gt;GetFeatures returns a collection of visible and selectable features that intersects a geometry.&lt;/P&gt;&lt;P&gt;If you're only getting the top layer, that may be the only layer selectable in the TOC.&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2022 02:41:13 GMT</pubDate>
    <dc:creator>sjones_esriau</dc:creator>
    <dc:date>2022-05-24T02:41:13Z</dc:date>
    <item>
      <title>select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176449#M8172</link>
      <description>&lt;P&gt;Hi - I would to select features from a specific layer using the map tool.&amp;nbsp; I've found the snippet below, but it selects features from the top-most layer in the toc only:&lt;/P&gt;&lt;P&gt;return QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;var mapView = MapView.Active;&lt;BR /&gt;if (mapView == null)&lt;BR /&gt;return true;&lt;/P&gt;&lt;P&gt;//Get all the features that intersect the sketch geometry and flash them in the view.&lt;BR /&gt;var results = mapView.GetFeatures(geometry);&lt;BR /&gt;return true;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there anyway to specify the layer by name like the code below and then perform the select/get features on the specified layer only:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals("MSA_Class"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 15:49:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176449#M8172</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-05-23T15:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176507#M8174</link>
      <description>&lt;P&gt;You could use a `SpatialQueryFilter` to search on the layer.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals("MSA_Class"));

var spatialFilter = new SpatialQueryFilter
{
    FilterGeometry = geometry,
    SpatialRelationship = SpatialRelationship.Intersects
};

using (var featureCursor = layer.Search(spatialFilter, false))
{
    while (featureCursor .MoveNext())
    {
        using (var feature = featureCursor.Current)
        {
            // Feature-specific code here
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 23 May 2022 17:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176507#M8174</guid>
      <dc:creator>tempStephenRhea_NV5</dc:creator>
      <dc:date>2022-05-23T17:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176565#M8175</link>
      <description>&lt;P&gt;Thanks Stephen - I'm getting a called on wrong thread exception error&amp;nbsp; on the layer.Search method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;var mapView = MapView.Active;&lt;BR /&gt;if (mapView == null)&lt;BR /&gt;return true;&lt;BR /&gt;var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals("MSA_Class"));&lt;/P&gt;&lt;P&gt;var spatialFilter = new SpatialQueryFilter&lt;BR /&gt;{&lt;BR /&gt;FilterGeometry = geometry,&lt;BR /&gt;SpatialRelationship = SpatialRelationship.Intersects&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;using (var featureCursor = layer.Search(spatialFilter, false))&lt;BR /&gt;{&lt;BR /&gt;while (featureCursor.MoveNext())&lt;BR /&gt;{&lt;BR /&gt;using (var feature = featureCursor.Current)&lt;BR /&gt;{&lt;BR /&gt;// Feature-specific code here&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return true;&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 18:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176565#M8175</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-05-23T18:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176698#M8177</link>
      <description>&lt;P&gt;GetFeatures returns a collection of visible and selectable features that intersects a geometry.&lt;/P&gt;&lt;P&gt;If you're only getting the top layer, that may be the only layer selectable in the TOC.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 02:41:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176698#M8177</guid>
      <dc:creator>sjones_esriau</dc:creator>
      <dc:date>2022-05-24T02:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176788#M8181</link>
      <description>&lt;P&gt;Are you running that query within a background or worker thread? I'm pretty sure most map interaction has to be done on the main calling thread (MCT), and the QueuedTask runs its function there. However, if you're using this in a separate thread you've created, you may not be able to access the map.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 12:58:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176788#M8181</guid>
      <dc:creator>tempStephenRhea_NV5</dc:creator>
      <dc:date>2022-05-24T12:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: select layer by geometry</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176800#M8182</link>
      <description>&lt;P&gt;the exception went away when I changed:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;using (var featureCursor = layer.Search(spatialFilter, false))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;using (var featureCursor = layer.Search(spatialFilter))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;still only getting the top layer selected -- I'll take a look at the selectability of the layers as suggested below&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 13:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/select-layer-by-geometry/m-p/1176800#M8182</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-05-24T13:18:50Z</dc:date>
    </item>
  </channel>
</rss>

