<?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: Run a python code in ArcGIS in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745673#M57661</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much again. I really appreciate it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2015 20:59:51 GMT</pubDate>
    <dc:creator>DuminduJayasekera</dc:creator>
    <dc:date>2015-01-30T20:59:51Z</dc:date>
    <item>
      <title>Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745646#M57634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to make it run the following code in arcGIS but this is not written to run in arcgis but in visual studio. I tried but it DOES NOT work. Can someone help me to write thin in python so that I can add as a script in ArcGIS.? I am planning to import this as a script after making this a working code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is highy appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&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;from arcpy import env&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Check out the ArcGIS Spatial Analyst extension license&lt;/P&gt;&lt;P&gt;arcpy.CheckOutExtension("Spatial")&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;arcpy.env.scratchWorkspace = "c:\temp\tmp"&lt;/P&gt;&lt;P&gt;env.workspace = "c:\DEMPreProcess"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LULC = Raster("C:\DEMPreProcess\VietnamLULC_Resample.tif")&lt;/P&gt;&lt;P&gt;Simard = Raster("C:\DEMPreProcess\MajoritySTOht.tif")&lt;/P&gt;&lt;P&gt;resultmap = Simard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i in range(1,14):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i == 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 4:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 5:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 6:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 7:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 8:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 9:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 10:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 11:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 12:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 13:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif i == 14:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = 0.3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resultmap = Con(LULC == i,Simard*number,resultmap)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;resultmap.save("C:\DEMPreProcess\MajoritySTOhtPer.tif")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 01:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745646#M57634</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T01:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745647#M57635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the error message? and what is it supposed to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 01:38:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745647#M57635</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-01-14T01:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745648#M57636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to python but what I want to write a script in python to take the integer values from&amp;nbsp; i=1 to 14 in &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;VietnamLULC_Resample.tif file and then multiplied by the interger values in the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MajoritySTOht.tif file for each corresponding i.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I need to include this process as a pythin script to this model builder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks and help is appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;IMG alt="pic.bmp" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/50793_pic.bmp" style="width: 620px; height: 389px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 02:09:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745648#M57636</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T02:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745649#M57637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is hard to tell from your code formatting, but I think your last two lines should be indented so that they are within the for loop...currently, they are outside the loop by all appearances.&amp;nbsp; You should use the &lt;STRONG&gt;Advanced Editor&lt;/STRONG&gt;, then &lt;STRONG&gt;select &amp;gt;&amp;gt;&lt;/STRONG&gt; and choose &lt;STRONG&gt;Syntax Highlighting&lt;/STRONG&gt; and format your code in the original thread to &lt;STRONG&gt;Python syntax&lt;/STRONG&gt; to make it easier to read and so indentation can be confirmed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 03:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745649#M57637</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-01-14T03:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745650#M57638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not reclassify the LULC raster (holding the 14 integer values) using ReclassByASCIIFile with a ASCII file that has the relation between the input and output values like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; 1 : 0.4&lt;/P&gt;&lt;P&gt; 2 : 0.4&lt;/P&gt;&lt;P&gt; 3 : 0.4&lt;/P&gt;&lt;P&gt; 4 : 0.4&lt;/P&gt;&lt;P&gt; 5 : 0.4&lt;/P&gt;&lt;P&gt; 6 : 0.3&lt;/P&gt;&lt;P&gt; 7 : 0.3&lt;/P&gt;&lt;P&gt; 8 : 0.3&lt;/P&gt;&lt;P&gt; 9 : 0.3&lt;/P&gt;&lt;P&gt;10 : 0.3&lt;/P&gt;&lt;P&gt;11 : 0&lt;/P&gt;&lt;P&gt;12 : 0.3&lt;/P&gt;&lt;P&gt;13 : 0&lt;/P&gt;&lt;P&gt;14 : 0.3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and then multiply the reclassified raster by the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Simard raster. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 03:25:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745650#M57638</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-14T03:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745651#M57639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code is run in Visual Studio but I want to convert it to pythin to include in the model bilder. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where can I find the Advanced editor and syntax highlighting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745651#M57639</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T18:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745652#M57640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the upper right corner of the editor (when editing a post) you will see the link "Use advanced editor". The code you supplied is Python code. It is possible that Visual Studio has been used to run it, but the IDE has no influence on the code itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:41:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745652#M57640</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-14T18:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745653#M57641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK. But How can I include this code into my model buider environment? and to make it run?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and highly appreciate your help. I am very new to python and GIS model builder. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:02:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745653#M57641</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T19:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745654#M57642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;The above code is run in Visual Studio&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What project type in VS allows you run python code?&amp;nbsp; Or are you executing a .bat file from the application you developed in Visual Studio (there's lots of different types of apps you can develop, VS is just the IDE). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745654#M57642</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-01-14T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745655#M57643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a new geoprocessing tool, set the source to your .py file, add the tool to your model.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:12:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745655#M57643</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-01-14T19:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745656#M57644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can include a small subset of your data I can have a look at the calculation you intent to do, since doing 14 calculations for what can be done in one, doesn't sound correct to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would have to adapt the code to allow for parameters: &lt;SPAN style="font-family: Consolas;"&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Understanding_script_tool_parameters/00150000002s000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#/Understanding_script_tool_parameters/00150000002s000000/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose all things listed below should be change into parameters. So something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: Consolas;"&gt;env.workspace = arcpy.GetParameterAsText(0)
LULC = Raster(arcpy.GetParameterAsText(1))
Simard = Raster(arcpy.GetParameterAsText(2))&lt;/SPAN&gt;

&lt;SPAN style="font-family: Consolas;"&gt;resultmap.save(arcpy.GetParameterAsText(3))
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = "c:\DEMPreProcess"
LULC = Raster("C:\DEMPreProcess\VietnamLULC_Resample.tif")
Simard = Raster("C:\DEMPreProcess\MajoritySTOht.tif")

resultmap.save("C:\DEMPreProcess\MajoritySTOhtPer.tif")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:43:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745656#M57644</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T07:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745657#M57645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please illustrate how to do that? I am totally new to this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again and appreciate it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:39:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745657#M57645</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T19:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745658#M57646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000006000000http://"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000006000000http://&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:43:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745658#M57646</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2015-01-14T19:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745659#M57647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG __jive_id="51096" alt="pic.bmp" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/51096_pic.bmp" style="width: 620px; height: 374px;" /&gt;&lt;/P&gt;&lt;P&gt;Thanks Bakker for your willingness to help. I need to somehow include python code process to the blue color "python code process" as a tool as shown in the figure above. Please download the script, and input files (MajoritySTOht.tif, and viet_LULC_30.tif) using the following web links below. The output of the python code process is "MajoritySTOhtPer.tif" (please look in the code) and will be used to link to Focal Statistics process in the model builder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bft.usu.edu/s467k" style="text-decoration: underline; color: #196ad4; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background: #ffffff;" target="_blank"&gt;https://bft.usu.edu/s467k&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bft.usu.edu/mt9zj" style="text-decoration: underline; color: #196ad4; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background: #ffffff;" target="_blank"&gt;https://bft.usu.edu/mt9zj&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bft.usu.edu/wqlyb" style="text-decoration: underline; color: #196ad4; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background: #ffffff;" target="_blank"&gt;https://bft.usu.edu/wqlyb&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Link to download my ArcGIs tool&lt;/P&gt;&lt;P&gt;&lt;A href="https://bft.usu.edu/tlxxz" style="text-decoration: underline; color: #196ad4; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background: #ffffff;" target="_blank"&gt;https://bft.usu.edu/tlxxz&lt;/A&gt;&lt;SPAN style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Thanks and highly appreciate your help. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 20:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745659#M57647</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T20:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745660#M57648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A few remarks:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;viet_LULC_30.tif&lt;/EM&gt; is a large raster (2GB) with a resolution of 30 meters, but the detail inside is only using a resolution of 450m (was this raster resampled with a factor 15? If so, why?). I notice that it has values from -1 to 16. In your code you only account for value 1 to 14.Values -1, 0, 15 and 16 will remain untouched. Is that correct?&lt;/LI&gt;&lt;LI&gt;One of the downloads (WRFV3.6.1.TAR.gz) seems to be C code. I asume this should not be used.&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;MajoritySTOht.tif&lt;/EM&gt; is not included in the downloads. Pease attach the version with 450m resolution to keep things small.&lt;/LI&gt;&lt;LI&gt;The Toolbox Lee_Filtering contains 5 models. I won't touch these, I will simply show how to include the script in the model&lt;/LI&gt;&lt;LI&gt;The script SRTMCorrectionTreeOffsets.py contains the code you originally po&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 20:36:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745660#M57648</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-14T20:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745661#M57649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;never mind...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find attached the toolbox with the script tool inside. You can drag and drop this script tool into your model and connect it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="model_script.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/51099_model_script.png" style="width: 620px; height: 364px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code of the script is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy.sa import *

#Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "IN_MEMORY"

# input parameters
LULC = arcpy.GetParameterAsText(0) # r"D:\Xander\GeoNet\LULC\data\viet_LULC_450.tif"
Simard = arcpy.GetParameterAsText(1) # r"D:\Xander\GeoNet\LULC\data\MajoritySTOht_450.tif"
ras_LULC = Raster(LULC)
ras_Simard = Raster(Simard)

# output parameter
result = arcpy.GetParameterAsText(2) # r"D:\Xander\GeoNet\LULC\data\MajoritySTOhtPer.tif"

# internal vars
fld_value = "Value"
fld_remap = "remap"

# remap dictionary
dct = {1 : 0.4, 2 : 0.4, 3 : 0.4, 4 : 0.4, 5 : 0.4, 6 : 0.3, 7 : 0.3,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 : 0.3, 9 : 0.3, 10 : 0.3, 11 : 0, 12 : 0.3, 13 : 0, 14 : 0.3}

# add field for remap values
arcpy.AddField_management(ras_LULC, fld_remap, "DOUBLE")

# update the remap values base on dictionary
curs = arcpy.UpdateCursor(ras_LULC)
for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; val = row.getValue(fld_value)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if val in dct:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remap = dct[val]
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # what should be done with the values in the TIFF that are not in your list?
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remap = 0 # val?
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(fld_remap, remap)
&amp;nbsp;&amp;nbsp;&amp;nbsp; curs.updateRow(row)
del curs, row

# remap the raster
ras_remap = Lookup(ras_LULC, fld_remap)

# create result
resultmap = ras_Simard * ras_remap
resultmap.save(result)

# release the SA license
arcpy.CheckInExtension("Spatial")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:43:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745661#M57649</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T07:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745662#M57650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The process used to obtain viet_LULC_30.tif is correct. As you said it was resampled to 30 m. If you open the attribute table, the values are ranging from 0 to 16 and if you see into layer properties min is 0 and max is 16. So, I don't understand where you saw -1. Yes the code was written to use from 1 to 14 because those are the land use types I am interested. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK. How can I convert that to python code? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the link to download &lt;EM style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MajoritySTOht.tif&lt;/EM&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp; file&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bft.usu.edu/t3vh9" title="https://bft.usu.edu/t3vh9"&gt;https://bft.usu.edu/t3vh9&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please open the Vietnam_Test tool that I am using to perform the GIS process and calculations. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 21:36:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745662#M57650</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T21:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745663#M57651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to import your tool and tried running. See the picture below. I got an error message (See the image)&lt;/P&gt;&lt;P&gt;As far as I see you are using tif files of 450 m resolution. But input rasters are in 30 m resolutions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="layout.bmp" class="jive-image image-1" height="253" src="https://community.esri.com/legacyfs/online/51197_layout.bmp" style="width: 360px; height: 252.631578947368px;" width="360" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error.bmp" class="jive-image image-2" src="https://community.esri.com/legacyfs/online/51198_error.bmp" style="width: 620px; height: 351px;" /&gt;&lt;/P&gt;&lt;P&gt;I appreciate your help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 22:12:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745663#M57651</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-14T22:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745664#M57652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep that is a memory problem (due to the size of your raster). You can change the "IN_MEMORY" on line 8 to an existing file geodatabase or scratch geodatabase, so it doesn't try to do it in memory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 00:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745664#M57652</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-15T00:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Run a python code in ArcGIS</title>
      <link>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745665#M57653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again for the reply. If I revise line 8 by like this will it work? or can I give a path? like this c:\temp\tmp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "scratch geodatabase"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 00:34:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-a-python-code-in-arcgis/m-p/745665#M57653</guid>
      <dc:creator>DuminduJayasekera</dc:creator>
      <dc:date>2015-01-15T00:34:14Z</dc:date>
    </item>
  </channel>
</rss>

