<?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: Why is this code does not work in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648083#M50458</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now I see the while loop, but you are limiting yourself to just 2 input rasters, right?&amp;nbsp; ( 0,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even still, changing up your workspace environments can get confusing; it&amp;nbsp;does for me anyway.&amp;nbsp; What if you&amp;nbsp; set variables instead of workspaces like :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;in_ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\path\to\in\rasters'&lt;/SPAN&gt;
out_ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\path\to\out\rasters'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You might also reconsider the while loop in favor of a for loop like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;in_raster_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListRasters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; in_raster_list&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#do what you need to do&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#to all of the rasters by using r&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#as the iterator....‍‍‍‍‍‍‍‍‍‍‍‍‍&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;&lt;/P&gt;&lt;P&gt;As a matter of personal style, I try to avoid counters, opting rather to step through a list until it's exhausted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:29:13 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-12-12T03:29:13Z</dc:date>
    <item>
      <title>Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648078#M50453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="direction: ltr;"&gt;I am tring to warb many rasters to others using python in ArcMap, But I field, I need help.&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;I have two workspaces, because first contain many rasters with correct coordinate , and second workspace contain rasters with incorrect&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;coordinate&amp;nbsp;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;I need to warb rasters in socand worksapce to rasters in first workspace.&lt;/P&gt;&lt;P style="direction: ltr;"&gt;&lt;/P&gt;&lt;P style="direction: ltr;"&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;i = 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;while i &amp;lt;= 1:&lt;/P&gt;&lt;P&gt;inRasterworkspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI_R'&lt;BR /&gt; #inRasterworkspace = arcpy.GetParameterAsText(0)&lt;BR /&gt; arcpy.env.workspace = inRasterworkspace&lt;BR /&gt; inRasters = arcpy.ListRasters()&lt;BR /&gt; inRaster = inRasters&lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;SoTop=arcpy.GetRasterProperties_management(inRaster , "TOP")&lt;BR /&gt; SoLeft=arcpy.GetRasterProperties_management(inRaster , "LEFT")&lt;BR /&gt; SoRight=arcpy.GetRasterProperties_management(inRaster , "RIGHT")&lt;BR /&gt; SoBottom=arcpy.GetRasterProperties_management(inRaster , "BOTTOM")&lt;BR /&gt; Source_pnt = '\''+ str(SoLeft) + ' ' + str(SoTop) + '\' ;' + str(SoRight) + ' ' + str(SoTop) + '\' ;' + str(SoLeft) + ' ' + str(SoBottom)+'\''&lt;/P&gt;&lt;P&gt;# ========================&lt;BR /&gt; taRasterworkspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI2018'&lt;BR /&gt; #taRasterworkspace = arcpy.GetParameterAsText(1)&lt;BR /&gt; arcpy.env.workspace = taRasterworkspace&lt;BR /&gt; taRasters = arcpy.ListRasters('*', 'jpg')&lt;BR /&gt; taRaster = taRasters&lt;I&gt; &lt;BR /&gt; &lt;BR /&gt; TaTop=arcpy.GetRasterProperties_management(taRaster , "TOP")&lt;BR /&gt; TaLeft=arcpy.GetRasterProperties_management(taRaster , "LEFT")&lt;BR /&gt; TaRight=arcpy.GetRasterProperties_management(taRaster , "RIGHT")&lt;BR /&gt; TaBottom=arcpy.GetRasterProperties_management(taRaster , "BOTTOM")&lt;BR /&gt; Target_pnt = '\''+ str(TaLeft) + ' ' + str(TaTop) + '\' ;' + str(TaRight) + ' ' + str(TaTop) + '\' ;' + str(TaLeft) + ' ' + str(TaBottom)+'\''&lt;/I&gt;&lt;/P&gt;&lt;P&gt;# ========================&lt;BR /&gt; arcpy.env.workspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI2018'&lt;BR /&gt; arcpy.env.overwriteOutput = True&lt;BR /&gt; arcpy.Warp_management(str(taRaster), Source_pnt, Target_pnt, str(taRaster[:-4])+'tif', "POLYORDER2", "BILINEAR")&lt;/P&gt;&lt;P&gt;# ========================&lt;BR /&gt; i = i + 1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 14:54:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648078#M50453</guid>
      <dc:creator>Abualgheth_J__M_Naji</dc:creator>
      <dc:date>2018-07-31T14:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648079#M50454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please place your code in the body of the question. Many will not download and unzip documents for computer security reasons, so you're shutting yourself out from assistance.&amp;nbsp; Be sure to specify what you are attempting to accomplish and what your actual result is, especially any errors (as text, not as an image)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:03:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648079#M50454</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2018-07-31T15:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648080#M50455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;!The problem is in the varibales, the take the same value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inRaster&lt;/P&gt;&lt;P&gt;taRaster&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Source_pnt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;Target_pnt&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:15:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648080#M50455</guid>
      <dc:creator>Abualgheth_J__M_Naji</dc:creator>
      <dc:date>2018-07-31T15:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648081#M50456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Vince mentions, you may want to articulate the objective.&amp;nbsp; My question is why are you using a while loop and why do you change workspace environments so many times?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:36:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648081#M50456</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-07-31T15:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648082#M50457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="direction: ltr;"&gt;I have two workspaces, because first contain many rasters with correct coordinate , and second workspace contain rasters with incorrect &lt;SPAN&gt;coordinate&amp;nbsp;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="direction: ltr;"&gt;I need to warb rasters in socand worksapce to rasters in first workspace.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:48:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648082#M50457</guid>
      <dc:creator>Abualgheth_J__M_Naji</dc:creator>
      <dc:date>2018-07-31T15:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648083#M50458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now I see the while loop, but you are limiting yourself to just 2 input rasters, right?&amp;nbsp; ( 0,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even still, changing up your workspace environments can get confusing; it&amp;nbsp;does for me anyway.&amp;nbsp; What if you&amp;nbsp; set variables instead of workspaces like :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;in_ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\path\to\in\rasters'&lt;/SPAN&gt;
out_ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\path\to\out\rasters'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You might also reconsider the while loop in favor of a for loop like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;in_raster_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListRasters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; in_raster_list&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#do what you need to do&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#to all of the rasters by using r&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#as the iterator....‍‍‍‍‍‍‍‍‍‍‍‍‍&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;&lt;/P&gt;&lt;P&gt;As a matter of personal style, I try to avoid counters, opting rather to step through a list until it's exhausted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648083#M50458</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T03:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648084#M50459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="direction: ltr;"&gt;You do one rasterlist, while I have two rasterlist. first one to raster with correct coordinate , and second raster list for rasters with incorrect doordinate.&lt;/P&gt;&lt;P style="direction: ltr;"&gt;&lt;/P&gt;&lt;P style="direction: ltr;"&gt;&lt;/P&gt;&lt;P style="direction: ltr;"&gt;in other way :&lt;/P&gt;&lt;P style="direction: ltr;"&gt;I have 500 rasters had georeferenced&amp;nbsp; , and others (500 rasters) need to georeference .&lt;/P&gt;&lt;P style="direction: ltr;"&gt;How I can do georeference second&amp;nbsp;group to first group without using georeference toolbar? because they need long time to use toolbar?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648084#M50459</guid>
      <dc:creator>Abualgheth_J__M_Naji</dc:creator>
      <dc:date>2018-07-31T17:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648085#M50460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know of a way to georeference rasters/images to ground truthing locations in an automated fashion.&amp;nbsp; Unless each of them are of the exact same area, and even then I'm thinking you'd only be able to reference the corners or extents; that's only 4 points of reference which is borderline at best for for you least mean squares errors...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:24:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648085#M50460</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-07-31T18:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648086#M50461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="direction: ltr;"&gt;There are a tool with name (warp) in arctoolbox, it let us to referance image to correct xy data, I try to use this tool in python to referance many rasters, I use the top code. But there is small problem.&lt;/P&gt;&lt;P style="direction: ltr;"&gt;By the way, thank you for your tring to help me. And I will try maybe I will get the solution .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:52:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648086#M50461</guid>
      <dc:creator>Abualgheth_J__M_Naji</dc:creator>
      <dc:date>2018-07-31T18:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code does not work</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648087#M50462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking at the tool online help, if I understand it correctly you'd need the same number of reference points and control points and then they need to be ordered in such a fashion that RasterPoint1 is 'warped' to ControlPoint1 etc etc.&amp;nbsp; With as many rasters as you have to reference, I don't see how this is possible to automate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best of luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2018 19:35:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-does-not-work/m-p/648087#M50462</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-07-31T19:35:18Z</dc:date>
    </item>
  </channel>
</rss>

