<?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: Crashing on arcpy.sa.PathAllocation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510253#M40098</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think it's safer to use positional parameters like they do in the help, instead of names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The arcpy.sa functions return a raster object. So, maybe something like this using PathDistance will work better?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from arcpy.sa import *
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Distance_method == "model-cost": 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## calculates the least cost distance to the nearest lineage point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## the result is written directly to lineage_dist_gridname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distRaster = PathDistance(Raster("lin_lyr"),maxent_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distRaster.save(lineage_dist_gridname)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:20:59 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T22:20:59Z</dc:date>
    <item>
      <title>Crashing on arcpy.sa.PathAllocation</title>
      <link>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510252#M40097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope one of you can help me...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;for &lt;/SPAN&gt;&lt;SPAN&gt;loop, my code selects in turn, a different set of points in a layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It then runs PathAllocation for the selected points, as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Distance_method == "model-cost": 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## calculates the least cost distance to the nearest lineage point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## the result is written directly to lineage_dist_gridname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = arcpy.sa.PathAllocation(in_source_data="lin_lyr", in_cost_raster=maxent_model, out_distance_raster=lineage_dist_gridname)&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lin_dist = arcpy.sa.Raster(lineage_dist_gridname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers_to_delete.append(lineage_dist_gridname)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that it always fails the second time the loop hits the PathAllocation line.&amp;nbsp; The message is: python.exe has stopped working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This behavior is independent of the particular data selected on that iteration - I've tried changing the dataset, and the order, and it still fails on the second pass through the loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The filename defined in lineage_dist_gridname is different on each iteration, so it is not a problem of overwriting the raster created on the first iteration.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone hit a similar crash or has some idea about the cause?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;many thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 12:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510252#M40097</guid>
      <dc:creator>DanRosauer</dc:creator>
      <dc:date>2012-10-01T12:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing on arcpy.sa.PathAllocation</title>
      <link>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510253#M40098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think it's safer to use positional parameters like they do in the help, instead of names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The arcpy.sa functions return a raster object. So, maybe something like this using PathDistance will work better?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from arcpy.sa import *
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Distance_method == "model-cost": 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## calculates the least cost distance to the nearest lineage point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## the result is written directly to lineage_dist_gridname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distRaster = PathDistance(Raster("lin_lyr"),maxent_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distRaster.save(lineage_dist_gridname)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510253#M40098</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T22:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Crashing on arcpy.sa.PathAllocation</title>
      <link>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510254#M40099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Curtis, that worked nicely.&amp;nbsp;&amp;nbsp; I thought that pathdistance wouldn't do what I needed, but it does, it's simpler, and it works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2012 00:42:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crashing-on-arcpy-sa-pathallocation/m-p/510254#M40099</guid>
      <dc:creator>DanRosauer</dc:creator>
      <dc:date>2012-10-05T00:42:55Z</dc:date>
    </item>
  </channel>
</rss>

