<?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: How to query a specific layer from a Feature Service in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137481#M7045</link>
    <description>&lt;P&gt;Looking at it again, a &lt;STRONG&gt;layer&lt;/STRONG&gt; doesn't have a &lt;STRONG&gt;title&lt;/STRONG&gt; property. The parent item has a title, but the layers have &lt;STRONG&gt;properties&lt;/STRONG&gt;, in which you can find a &lt;STRONG&gt;name&lt;/STRONG&gt;, as shown in the other code block you quoted.&lt;/P&gt;&lt;P&gt;To get the feature service itself, you have to reference the parent item. This snippet would return a list of all Feature Layers in your search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;items = gis.content.search('some string', item_type='Feature Service')

[a.url for b in items for a in b.layers]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To filter this list, we can include a simple ternary operator in the same line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[a for b in items for a in b.layers if a.properties['name'] == 'WETTBEWERBER']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this on my own layers, and searching for the layer name "Records" across a bunch of layers yielded the following:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;['https://maps.co.kendall.il.us/server/rest/services/Cadastral/Ordinance_Fabric/FeatureServer/1',
 'https://maps.co.kendall.il.us/server/rest/services/Hosted/ord_fabric_hosted/FeatureServer/0']&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 26 Jan 2022 17:17:03 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-01-26T17:17:03Z</dc:date>
    <item>
      <title>How to query a specific layer from a Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137434#M7042</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to get the list of feature service which has a specific layer (for example WETTBEWERBER (the layer id is 0)) from a feature service,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;from arcgis.gis import GIS
gis = GIS(url='&lt;A href="https://pythonapi.playground.esri.com/portal" target="_blank" rel="noopener noreferrer"&gt;https://url/portal&lt;/A&gt;', username='arcgis_python', password='amazing_arcgis_123')

layer_items = gis.content.search(query="WETTBEWERBER", item_type="Feature Layer")
for layer in layer_items:
    if "WETTBEWERBER" in layer.title.upper():
        print(f"Layer name: {layer.title}, \tOwner: {layer.owner}, \tLayer ID: {layer.id}")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;But no results are printed out, but the layer WETTBEWERBER is present in most of my feature services. What can be done in this case ??&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have tried to get the layers first using the following code to check whether I can get the layers using the API and I can get the layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;layer_items = gis.content.search(query="5fg239sdsfs56sdfcs466s4f", item_type="Feature Service")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;item&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;self&lt;/SPAN&gt;&lt;SPAN&gt;.api_query_result:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = item.layers&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;for&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;lyr&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;layers:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(item)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;A href="http://item.id/" target="_blank" rel="noopener"&gt;item.id&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;item.url&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;lyr.properties[&lt;/SPAN&gt;&lt;SPAN&gt;"id"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;lyr.properties[&lt;/SPAN&gt;&lt;SPAN&gt;"name"&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;except&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Exception&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;as&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;e:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(e)&lt;BR /&gt;&lt;BR /&gt;I can get all the layers including the layer&amp;nbsp;WETTBEWERBER (0) in it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But I cannot list all the feature service which contains this particular layer, What am I doing wrong ??&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for the insights.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 26 Jan 2022 16:24:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137434#M7042</guid>
      <dc:creator>Aravinthkumar</dc:creator>
      <dc:date>2022-01-26T16:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a specific layer from a Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137442#M7043</link>
      <description>&lt;P&gt;layer.title.lower() would not match an all-caps string like "WETTBEWERBER". Did you mean "layer.title.upper()"?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 16:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137442#M7043</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-26T16:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a specific layer from a Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137449#M7044</link>
      <description>&lt;P&gt;Yes, sorry for the typo here it is "layer.title.upper()" I have updated the post.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 16:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137449#M7044</guid>
      <dc:creator>Aravinthkumar</dc:creator>
      <dc:date>2022-01-26T16:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a specific layer from a Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137481#M7045</link>
      <description>&lt;P&gt;Looking at it again, a &lt;STRONG&gt;layer&lt;/STRONG&gt; doesn't have a &lt;STRONG&gt;title&lt;/STRONG&gt; property. The parent item has a title, but the layers have &lt;STRONG&gt;properties&lt;/STRONG&gt;, in which you can find a &lt;STRONG&gt;name&lt;/STRONG&gt;, as shown in the other code block you quoted.&lt;/P&gt;&lt;P&gt;To get the feature service itself, you have to reference the parent item. This snippet would return a list of all Feature Layers in your search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;items = gis.content.search('some string', item_type='Feature Service')

[a.url for b in items for a in b.layers]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;To filter this list, we can include a simple ternary operator in the same line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[a for b in items for a in b.layers if a.properties['name'] == 'WETTBEWERBER']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this on my own layers, and searching for the layer name "Records" across a bunch of layers yielded the following:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;['https://maps.co.kendall.il.us/server/rest/services/Cadastral/Ordinance_Fabric/FeatureServer/1',
 'https://maps.co.kendall.il.us/server/rest/services/Hosted/ord_fabric_hosted/FeatureServer/0']&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Jan 2022 17:17:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137481#M7045</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-26T17:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a specific layer from a Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137504#M7046</link>
      <description>&lt;P&gt;Thank you for the detailed explanation, whether I should leave the query empty in the place of "some string" and kindly can you edit it with the exact syntax I cannot figure out from this, that will be really helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 17:51:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-a-specific-layer-from-a-feature/m-p/1137504#M7046</guid>
      <dc:creator>Aravinthkumar</dc:creator>
      <dc:date>2022-01-26T17:51:52Z</dc:date>
    </item>
  </channel>
</rss>

