<?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: Issues looping with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160447#M12294</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may want to try using make feature layer to isolate the country. You also might have a look at &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/analysis-toolbox/spatial-join.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/analysis-toolbox/spatial-join.htm"&gt;Spatial Join—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; which would do what you are trying to do&lt;/P&gt;&lt;P&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;MakeFeatureLayer_management&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;(contriesfcorlayer,yourlayer+ii,whereclause to get ii)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-feature-layer.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-feature-layer.htm"&gt;Make Feature Layer—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also wish to move your question to &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;​ or &lt;A href="https://community.esri.com/group/1519"&gt;python snippets&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Mar 2016 19:07:15 GMT</pubDate>
    <dc:creator>WesMiller</dc:creator>
    <dc:date>2016-03-09T19:07:15Z</dc:date>
    <item>
      <title>Issues looping with Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160446#M12293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm having a strange problem with Python in Arcmap. I have a map of Europe with layers of polygons for each country, as well as a single layer of many polygons covering all Europe describing the land use type. What I am trying to do is loop through each country, select all the land cover type polygons within that country, and assign their 'country' field equal to the country 2-letter code. My code is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;c= ["AT","BE","BG","CH","CY","CZ","DE","DK","EE","EL","ES","FI","FR","HR","HU","IE","IT","LT","LU","LV","MT","NL","NO","PL","PT","RO","SE","SI","SK","UK"]&lt;/P&gt;&lt;P&gt;for ii in c:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("EuropeCorine2006100mpoly",...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..."HAVE_THEIR_CENTER_IN",ii,0,"NEW_SELECTION","NOT_INVERT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management("EuropeCorine2006100mpoly","country","'%s'" %(ii),"PYTHON")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("EuropeCorine2006100mpoly","Corinepoly_%s"%(ii))&lt;/P&gt;&lt;P&gt;-------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code works for a single country, but then throws an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&amp;nbsp;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3.1\desktop10.3\arcpy\arcpy\management.py", line 7359, in SelectLayerByLocation&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e ExecuteError: ERROR 000622: Failed to execute (Select Layer By Location). Parameters are not valid. ERROR 000628: Cannot set input into parameter in_layer. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another strange thing is that if I just set the country manually (e.g. ii = "BE"), it works fine. But, if I try changing the country afterwards (e.g. ii = "IT") and running the code again, it throws the same error. BUT, if I close Arcmap and reopen it again, I can run the code and it works again for one country only. It makes no sense to me....can someone help?!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 15:58:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160446#M12293</guid>
      <dc:creator>WilliamZappa1</dc:creator>
      <dc:date>2016-03-09T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Issues looping with Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160447#M12294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may want to try using make feature layer to isolate the country. You also might have a look at &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/analysis-toolbox/spatial-join.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/analysis-toolbox/spatial-join.htm"&gt;Spatial Join—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; which would do what you are trying to do&lt;/P&gt;&lt;P&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;MakeFeatureLayer_management&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px;"&gt;(contriesfcorlayer,yourlayer+ii,whereclause to get ii)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-feature-layer.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-feature-layer.htm"&gt;Make Feature Layer—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also wish to move your question to &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;​ or &lt;A href="https://community.esri.com/group/1519"&gt;python snippets&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 19:07:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160447#M12294</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-03-09T19:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Issues looping with Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160448#M12295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ii in c returns a string, that is not what that parameter is looking for.&amp;nbsp;&amp;nbsp; Have you done this manually with your inputs? If it worked examine the structure in the Results window to get the syntax... or go with the spatial join.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 21:19:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160448#M12295</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-09T21:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Issues looping with Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160449#M12296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;​ mentions, you should have a look at the definition of the parameters in the tool &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-layer-by-location.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-layer-by-location.htm"&gt;Select Layer By Location—Help | ArcGIS for Desktop&lt;/A&gt; :&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship})&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The third parameter (&lt;EM&gt;select_features&lt;/EM&gt;) expects a feature layer (as &lt;A href="https://community.esri.com/migrated-users/16710"&gt;Wes Miller&lt;/A&gt; suggests) while you provide the two character string for the country. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 00:21:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-looping-with-python/m-p/160449#M12296</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-03-10T00:21:01Z</dc:date>
    </item>
  </channel>
</rss>

