<?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 Data tool for Python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179827#M13812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a modelbuilder tool called 'Select Data' that pulls a single &amp;nbsp;layer out of a group layer.&lt;/P&gt;&lt;P&gt;I am using Python to do geometric tracing and the outputs are group layers.&lt;/P&gt;&lt;P&gt;Does anyone know the Python equivalent of "Select Data"?&lt;/P&gt;&lt;P&gt;I guess I could cycle through and find the right layer, but if there's an easier way, I'd like to know.&lt;/P&gt;&lt;P&gt;I am assuming there is a (relatively) easy way to do this in Python. Otherwise, it would make no sense to deny Python this handy tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Apr 2017 19:56:47 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2017-04-06T19:56:47Z</dc:date>
    <item>
      <title>Select Data tool for Python?</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179827#M13812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a modelbuilder tool called 'Select Data' that pulls a single &amp;nbsp;layer out of a group layer.&lt;/P&gt;&lt;P&gt;I am using Python to do geometric tracing and the outputs are group layers.&lt;/P&gt;&lt;P&gt;Does anyone know the Python equivalent of "Select Data"?&lt;/P&gt;&lt;P&gt;I guess I could cycle through and find the right layer, but if there's an easier way, I'd like to know.&lt;/P&gt;&lt;P&gt;I am assuming there is a (relatively) easy way to do this in Python. Otherwise, it would make no sense to deny Python this handy tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 19:56:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179827#M13812</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-06T19:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179828#M13813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In arcpy/python you want to get&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/get-started/listing-data.htm"&gt;list things &lt;/A&gt;by their type. like list featureclasses etc.&amp;nbsp; Have a look there to begin with&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179828#M13813</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-04-06T20:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179829#M13814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Conversely, if you are working a map document you can &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/listlayers.htm"&gt;ListLayers&lt;/A&gt; and create a layer object of the&amp;nbsp;layer you need.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:06:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179829#M13814</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-04-06T20:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179830#M13815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. Yes, I would have to select the group layer output of the "FindPath" tool, then select (in this case) "NHD Flowlines" from the group.&lt;/P&gt;&lt;P&gt;I appreciate the tip. It probably wouldn't be too bad, but I was hoping there would be a single tool available for this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179830#M13815</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-06T20:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179831#M13816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. Looks like ESRI is going to make me work for this one &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;'Select Data' is very handy when you are in ModelBuilder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:12:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179831#M13816</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-06T20:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179832#M13817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so working outside of arcmap, there is the &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/mapping/introduction-to-arcpy-mp.htm"&gt;arcpy.mapping module&lt;/A&gt;... tuck that away since it may come in handy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179832#M13817</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-04-06T20:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179833#M13818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The help discusses using Select Data with this tool but indeed is missing guidance on how to best go at this in Python:&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/trace-geometric-network.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/trace-geometric-network.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Trace Geometric Network—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An issue here (mentioned in the tool help) is that&amp;nbsp;group layers are not supported in some environments.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;This is especially useful when publishing your model to ArcGIS Server, since group layers are not supported as an output parameter type from a geoprocessing task. Because they aren't supported as direct output, you need to use the &lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;Select Data&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt; tool to create a single (nongroup) layer for output.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I posted feedback to the help author that they should add some Python guidance to the help page.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We ran into this and the solution was (as Dan suggested) arcpy.mapping.ListLayers run on the group layer output. Below I use a list comphension to get the layer you want by search string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;trace_lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TraceGeometricNetwork_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Create a Mapping Layer out of the Group Layer&lt;/SPAN&gt;
glyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;trace_lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Extract the layer based on a search string&lt;/SPAN&gt;
tlyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;lyr &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;glyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"net"&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;lower&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# copy out to a feature class&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tlyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; tfeat&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179833#M13818</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179834#M13819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curtis... r1 ... repr(r1)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2017 16:14:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179834#M13819</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-04-10T16:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179835#M13820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, sorry I deleted my previous post, as I found the answer in an old email exchange, and you jumped on it too fast!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For future readers, my previous (deleted) post suggested examining the output of the trace geometric networks tool to figure out what to do next:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;r &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TraceGeometricNetwork_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
r1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# get output from result object&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;repr&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The reason to print both is because sometimes the str() and repr() of an object are different and looking at both can give you a clue what the tool actually returned if you are unsure.&lt;/P&gt;&lt;P&gt;In this case I think you'd get something like "Trace" for str() and '&amp;lt;Group layer geoprocessing object at 239478219821&amp;gt;' for repr()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:12:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179835#M13820</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179836#M13821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the information.&lt;/P&gt;&lt;P&gt;Having thunk on it over the weekend, I think there is a fairly straightforward solution in Python for my purposes.&lt;/P&gt;&lt;P&gt;With the trace tool, you can set the name of the output layer group.&lt;/P&gt;&lt;P&gt;The layer I am interested in is always (for now) "NHDFlowlines"&lt;/P&gt;&lt;P&gt;So, if I set the name of the output group as, "Downstream_Trace_Group" I can simply run:&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management("Downstream_Trace_Group\\NHDFlowlines",in_memory\downstream_trace_line")&lt;/P&gt;&lt;P&gt;I have not tried it, but I'm hoping it'll do the trick.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2017 17:55:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179836#M13821</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-10T17:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data for Pyton</title>
      <link>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179837#M13822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked:&lt;/P&gt;&lt;P&gt;# Process: Trace Geometric Network&lt;BR /&gt;arcpy.AddMessage("&amp;gt; Downstream Trace...")&lt;BR /&gt;dstg = "Downstream_Trace_Group"&lt;BR /&gt;arcpy.TraceGeometricNetwork_management(Geometric_Network, dstg, poe_copy, "TRACE_DOWNSTREAM", "", "", "", "", "", "NO_TRACE_ENDS", "NO_TRACE_INDETERMINATE_FLOW", "", "", "AS_IS", "", "", "", "AS_IS")&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(dstg+"\\NHDFLowline","c:\\scratch\\scratch.gdb\\test")&lt;/P&gt;&lt;P&gt;Appears to much simpler a problem to solve than I feared.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2017 20:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-data-tool-for-python/m-p/179837#M13822</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-04-10T20:44:01Z</dc:date>
    </item>
  </channel>
</rss>

