<?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: Making my script run faster in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687939#M53281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aleydis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use &lt;/SPAN&gt;&lt;A href="http://code.google.com/p/pyscripter/"&gt;PyScripter&lt;/A&gt;&lt;SPAN&gt; as my Python development environment. I find running a script from the Python command line window in ArcMap slower than running it from the IDE environment.&amp;nbsp; Also if you have a multicore processor maybe you could try and utilise them all? There is a great blog article showing a simple example &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/Dev/blogs/geoprocessing/archive/2011/08/29/Multiprocessing.aspx"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Nov 2011 14:39:50 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2011-11-08T14:39:50Z</dc:date>
    <item>
      <title>Making my script run faster</title>
      <link>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687937#M53279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to get the fastest and most efficient script to take each feature in a shapefile (it's a 60x60m grid with 10 million features) as a mask to cut a DTM and apply the surface volume tool to each resulting raster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This script needs 3 seconds per feature but bearing in mind that I have 10 million features this is too slow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea on how to improve it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy

arcpy.CheckOutExtension("3D")
arcpy.CheckOutExtension("spatial")

Fishnet60x60 = arcpy.GetParameterAsText(0)
MDT15 = arcpy.GetParameterAsText(1)
Area2D3D_txt = arcpy.GetParameterAsText(2)

try:

&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(Fishnet60x60)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idvalue = row.getValue("ID_GRID")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(Fishnet60x60, Fishnet60x60 + "_layer", "\"ID_GRID\" = '" + idvalue + "'", "", "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.ExtractByMask_sa(MDT15, Fishnet60x60 + "_layer", idvalue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SurfaceVolume_3d(idvalue, Area2D3D_txt, "ABOVE", "0", "1", "0")

except:

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(2))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2011 13:59:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687937#M53279</guid>
      <dc:creator>AleydisG__Pere</dc:creator>
      <dc:date>2011-11-08T13:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Making my script run faster</title>
      <link>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687938#M53280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can try using Split Raster to break up your analysis into smaller parts instead of the mask tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000009v000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000009v000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2011 14:13:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687938#M53280</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-11-08T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Making my script run faster</title>
      <link>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687939#M53281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aleydis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use &lt;/SPAN&gt;&lt;A href="http://code.google.com/p/pyscripter/"&gt;PyScripter&lt;/A&gt;&lt;SPAN&gt; as my Python development environment. I find running a script from the Python command line window in ArcMap slower than running it from the IDE environment.&amp;nbsp; Also if you have a multicore processor maybe you could try and utilise them all? There is a great blog article showing a simple example &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/Dev/blogs/geoprocessing/archive/2011/08/29/Multiprocessing.aspx"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2011 14:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687939#M53281</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2011-11-08T14:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Making my script run faster</title>
      <link>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687940#M53282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Quite right to worry about the performance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You certainly don't want 10 million featureclasses output, that will kill any file system.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The cup of coffee rule states:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"If any single process takes longer than a cup of coffee then interrupt it and &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;find a better way&lt;/SPAN&gt;&lt;SPAN&gt;."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just don't run a geoprocessing tool inside a cursor. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Why do you have to call it for each feature?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe just run the Polygon_Volume_3D tool once?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 09:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-my-script-run-faster/m-p/687940#M53282</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2011-11-09T09:23:51Z</dc:date>
    </item>
  </channel>
</rss>

