<?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: Automate creation of Cost Distance Raster with Python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494090#M16450</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas,&lt;/P&gt;&lt;P&gt;could you mark this question as answered...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 May 2016 08:03:55 GMT</pubDate>
    <dc:creator>NeilAyres</dc:creator>
    <dc:date>2016-05-20T08:03:55Z</dc:date>
    <item>
      <title>Automate creation of Cost Distance Raster with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494086#M16446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody&lt;/P&gt;&lt;P&gt;I need some help on the automation processin which I try to create several cost distance raster. In a polygon feature class I have several records and I should create for each record an individual cost distance raster. So far script looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;rCost = "U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Test.gdb\F_Offen_Final"&lt;BR /&gt;fcStart = r"U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Test.gdb\Startorte"&lt;BR /&gt;cursor = arcpy.SearchCursor(fcStart)&lt;BR /&gt;count = 1&lt;BR /&gt;for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcount = str(count)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CD = CostDistance(fcStart,rCost, "100000")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CD.save("U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Cost_Distance.gdb\C"+strcount)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count +=1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;It perfectly runs as many times I have records in the feature class, but the result is always the same for every cost distance raster as all records of the feature were selected for the creation of the cost distance raster instead of only one and the next one in the next loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;Any suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;Thomas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 07:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494086#M16446</guid>
      <dc:creator>ThomasWirth</dc:creator>
      <dc:date>2016-05-20T07:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Automate creation of Cost Distance Raster with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494087#M16447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your Cost Distance calculation is on the whole Feature Class in every loop and not just the cursor feature:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1463729383348855 jive_text_macro" data-renderedposition="34_8_1315_16" jivemacro_uid="_1463729383348855"&gt;&lt;SPAN style="color: #800000; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;CD = CostDistance(fcStart,rCost, "100000")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isolate the cursor feature by creating a temporary layer for each cursor row and run the Cost Distance on that layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 07:30:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494087#M16447</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-05-20T07:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Automate creation of Cost Distance Raster with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494088#M16448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At the moment your loop is not doing anything but using fcStart &amp;amp; rCost repeatedly.&lt;/P&gt;&lt;P&gt;If you want to create cost distances for each geometry in fcStart, you must read the geometry object.&lt;/P&gt;&lt;P&gt;btw, please use the advanced editor and python syntax for posting code.&lt;/P&gt;&lt;P&gt;And switch to using the da.cursor methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So something like this :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;with arcpy.da.SearchCursor(fcStart, ["SHAPE@"]) as Cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in Cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polyGeom = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CD = CostDistance(polyGeom, rCost, "100000")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:44:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494088#M16448</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-11T21:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Automate creation of Cost Distance Raster with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494089#M16449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. Now it works as i hoped for.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 07:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494089#M16449</guid>
      <dc:creator>ThomasWirth</dc:creator>
      <dc:date>2016-05-20T07:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Automate creation of Cost Distance Raster with Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494090#M16450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas,&lt;/P&gt;&lt;P&gt;could you mark this question as answered...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 08:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/automate-creation-of-cost-distance-raster-with/m-p/494090#M16450</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-05-20T08:03:55Z</dc:date>
    </item>
  </channel>
</rss>

