<?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: Path Distance erratic and crashes in a loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144770#M11249</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think first it would be best to share the entire script, since the error may be caused somewhere&amp;nbsp;else. Also when sharing code use instructions like those described here:&amp;nbsp;&lt;A href="https://community.esri.com/docs/DOC-8691"&gt;Posting code with Syntax Highlighting on GeoNet&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just copied you snippet of code and several syntax errors occurred:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;there is an additional quote on this line:&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;rAcs= arcpy.PathDistance_spatial('lyr', rCost, rSurface , rDir, HF, rVertical, VF, '"", 'BL.tif')&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;a space between the arcpy. and CostPath:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;rPath = arcpy. CostPath_spatial('lyr', rAcs, 'BL.tif', "EACH_CELL")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure those are not the errors that are causing your problems (since the code would not execute with those errors) but it is important to understand that it will make it much more difficult to help in case you don't share the actual code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case possible, share a part of your data too so we can see if the error or any strange behavior can be reproduced.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Oct 2017 23:00:27 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2017-10-25T23:00:27Z</dc:date>
    <item>
      <title>Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144761#M11240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using arcgis 10.5.1 64 bit.&lt;/P&gt;&lt;P&gt;I have a set of 10 point features that I am trying to connect using PathDistance. Each point has an id, say 0...9. Effectively I want to generate the path from 0 to 1, 1 to 2, and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using both my own tables to define vertical and horizontal factors. I have created these paths manually using the exact same factors. So I know those work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The two main files I am using are: 1) a sample DEM (5m resolution, tif) called &lt;EM&gt;test_dem.tif&amp;nbsp;&lt;/EM&gt; 2) a point shapefile test_loc.shp which contains 11 points with several columns but the main one used here is 'Id' column. These files and others used for the script can be found below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The files used for the vertical and horizontal factors are the following,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" height="508" style="border: 1px solid #c6c6c6;" width="259"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef;"&gt;&lt;TH style="width: 108px;"&gt;&lt;EM&gt;hsine.txt&lt;/EM&gt;&lt;/TH&gt;&lt;TH style="width: 128px;"&gt;&lt;STRONG&gt;&lt;EM&gt;vertical3.txt&lt;/EM&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="width: 108px;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;0 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;10 1.02&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;20 1.06&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;30 1.13&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;40 1.23&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;50 1.36&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;60 1.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;70 1.66&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;80 1.83&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;90 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;100 2.17&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;110 2.34&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;120 2.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;130 2.64&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;140 2.77&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;150 2.87&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;160 2.94&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;170 2.98&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 13px;"&gt;180 3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="width: 128px;"&gt;&lt;SPAN style="font-size: 12px;"&gt;-90 20000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-80 5000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-70 1500&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-60 300&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-50 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-40 40&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-30 12&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-20 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;-10 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;0 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;10 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;20 14&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;30 24&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;40 40&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;50 75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;60 180&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;70 750&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;80 1500&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;90 5000&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sa &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; sa
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; mng
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; math &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; pi

&lt;SPAN class="comment token"&gt;# Checking out SA extension&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;SAerror&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Exception&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CheckExtension&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Spatial'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Available'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CheckOutExtension&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Spatial'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; SAerror
&lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; SAerror&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Spatial Analyst license is unavailable!'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ExecuteError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetMessages&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# ArcGIS directories&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchWorkspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\SCRATCH'&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# input rasters&lt;/SPAN&gt;
rDEM &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\tst_dem.tif'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
shpFeat &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\testloc.shp'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# PARAMETERS&lt;/SPAN&gt;
deg2rad &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pi&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;180.0&lt;/SPAN&gt;
rad2deg &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;180.0&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;pi
wFactor &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.2&lt;/SPAN&gt;
I &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4.0&lt;/SPAN&gt;
wPthPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.75&lt;/SPAN&gt;
Gmax &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;5.0&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# path distance parameters&lt;/SPAN&gt;
rCost &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# use unit&lt;/SPAN&gt;
rSurface &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rDEM
rVertical &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rDEM
hCostfn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\hsine.txt'&lt;/SPAN&gt;
HF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;HfTable&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;hCostfn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
vCostfn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\vertical3.txt'&lt;/SPAN&gt;
VF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;VfTable&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;vCostfn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
maxDist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;
nbrfn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GIS\projects\network\potential\expd.txt'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Set geoprocessing environmental preferences&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rDEM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;cellSize &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rDEM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;meanCellHeight
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# INITIAL CONDITIONS&lt;/SPAN&gt;
rTPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rDEM &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rDEM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;maximum
rDirRel &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rTPot
rG0 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateConstantRaster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'FLOAT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;cellSize&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
rGmax &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateConstantRaster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Gmax&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'FLOAT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;cellSize&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
rGt_1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateConstantRaster&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'FLOAT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;cellSize&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# sample sequence&lt;/SPAN&gt;
pthseq &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# create a feature layer&lt;/SPAN&gt;
mng&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;shpFeat&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# MAIN&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; o&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;d &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; zip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pthseq&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; pthseq&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# lambda direction&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rDir &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Aspect&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rDirRel&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# CALCULATE PATH&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mng&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' "Id" = '&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;o&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# origin&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# accumulated cost surface&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rAcs&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;PathDistance&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rSurface&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rDir&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; HF&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rVertical&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; VF&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'rBL.tif'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; mng&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' "Id" = '&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;d&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# destination&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# path&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CostPath&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rAcs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'rBL.tif'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"EACH_CELL"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Con&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;IsNull&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pathFn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'path'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;o&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'_'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;d&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'.tif'&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPath&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pathFn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; rW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rG0 &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; rGt_1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; wFactor
&amp;nbsp;&amp;nbsp;&amp;nbsp; rMark &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rPath &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rGt_1 &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rGmax&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; I
&amp;nbsp;&amp;nbsp;&amp;nbsp; rGt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rGt_1 &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rW &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rMark
&amp;nbsp;&amp;nbsp;&amp;nbsp; rGt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'rGt.tif'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# DECAY&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPthPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FocalStatistics&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rGt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;NbrWeight&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;nbrfn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SUM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPthPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rPthPot&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;maximum &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; rPthPot
&amp;nbsp;&amp;nbsp;&amp;nbsp; rPthPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rPthPot &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rPthPot&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;maximum

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Update directional relation&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rDirRel &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rPthPot &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; wPthPot &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rTPot &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; wPthPot&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Update rGt_1&amp;nbsp; *** missing earlier ***&amp;nbsp; &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rGt_1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rGt&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;/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;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;/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;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;/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;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;/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;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;/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;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;/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;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;/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;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;/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;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;/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;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Overall, I get very weird behavior. Some times, it will fail when trying to generate the backlink. In other occasions, it will calculate the first path and then fail.&amp;nbsp;It will calculate three&amp;nbsp;paths and fail. Only once it has ran through the entire sequence. After crashing I make sure to delete all possible files (usually the backlink file is created but it is corrupted).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried many things:&lt;/P&gt;&lt;P&gt;1. Creating a fresh feature layer and erasing it at the end of each iteration.&lt;/P&gt;&lt;P&gt;2. Generating with each iteration different feature layers, one for the origin and another for the destination, and deleting them after each iteration.&lt;/P&gt;&lt;P&gt;3. I have tried saving to the disk the layer feature as well as all the other rasters (I set arcpy to overwrite).&lt;/P&gt;&lt;P&gt;4. I have tried saving to the disk the backlink&lt;/P&gt;&lt;P&gt;5. I have used relative and absolute filenames.&lt;/P&gt;&lt;P&gt;6. I am using only .tif files&lt;/P&gt;&lt;P&gt;7. I have use try...except to catch information about the error with no success&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have spent much time reading through the different forums, etc. I know there were problems with this method in previous iterations of the software. The lack of any feedback relating to possible errors is a real problem! Often it will be python that crashes all together.&amp;nbsp; It is very finicky, there are certain Horizontal Factor settings (even those found in the help pages) that will not generate a complete cost accumulation raster. This is not my case though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is whether there is something that I am missing, something that needs to be reset or deleted? or perhaps someone can suggest how to find more information after the procedure fails???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marc&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144761#M11240</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2021-12-11T07:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144762#M11241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your script doesn't set any environment factors such as extent, cell size, snap raster etc. Try to explicitly set those prior to working with rasters to remove the potential for erratic behaviour, particularly if you are experiencing it between runs of the same code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 19:50:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144762#M11241</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-25T19:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144763#M11242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Indeed, all of that was done previously. All environmental variables and working directories were set up before creating anything or making any selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 20:06:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144763#M11242</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T20:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144764#M11243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So to clarify, there are parts of your script not present? Global settings in arcmap need nor persist even within a session.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 20:15:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144764#M11243</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-25T20:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144765#M11244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes... correct I did not include the rest of the code. Up to this point it had to do with several settings. Everything runs fine up to there (I have check this several times) it is only when I get into the loop that I encounter the behavior I described. Some times it runs fine other it does not.&lt;/P&gt;&lt;P&gt;Could you elaborate on what you mean that 'Global settings in arcmap need nor persist...'. Presumably if I define environmental and set overwrite to True within a script, those will be preserved,no?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 20:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144765#M11244</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T20:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144766#M11245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No... things like&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/env.htm"&gt;arcpy.env &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/extent.htm"&gt;arcpy.extent&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But check each tools' script and Environments section (bottom of each page) to see which environments are supportes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 21:25:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144766#M11245</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-25T21:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144767#M11246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did that... is there any known memory bug with this routine? I just cannot understand why is so unpredictable!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 22:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144767#M11246</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T22:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144768#M11247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Esri support&lt;A href="http://support.esri.com/en/Search-Results#search?q=pathdistance&amp;amp;content-type=Bugs"&gt;&lt;STRONG&gt;... PathDistance&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and&lt;A href="http://support.esri.com/en/Search-Results#search?q=pathdistance"&gt; PathDistance in general in Esri Support&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 22:27:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144768#M11247</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-25T22:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144769#M11248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks... there does not seem to be&amp;nbsp;anything&amp;nbsp;&amp;nbsp;there that seems to point to any causes or solutions. Thanks nonetheless.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 22:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144769#M11248</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T22:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144770#M11249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think first it would be best to share the entire script, since the error may be caused somewhere&amp;nbsp;else. Also when sharing code use instructions like those described here:&amp;nbsp;&lt;A href="https://community.esri.com/docs/DOC-8691"&gt;Posting code with Syntax Highlighting on GeoNet&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just copied you snippet of code and several syntax errors occurred:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;there is an additional quote on this line:&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;rAcs= arcpy.PathDistance_spatial('lyr', rCost, rSurface , rDir, HF, rVertical, VF, '"", 'BL.tif')&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;a space between the arcpy. and CostPath:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;rPath = arcpy. CostPath_spatial('lyr', rAcs, 'BL.tif', "EACH_CELL")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure those are not the errors that are causing your problems (since the code would not execute with those errors) but it is important to understand that it will make it much more difficult to help in case you don't share the actual code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case possible, share a part of your data too so we can see if the error or any strange behavior can be reproduced.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 23:00:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144770#M11249</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-10-25T23:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144771#M11250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xander... I will repost with all the script and the data. keep tuned&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 23:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144771#M11250</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T23:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144772#M11251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just reposted the script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 23:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144772#M11251</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-25T23:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144773#M11252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xander... I will leave it to you now that the script has appeared &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 23:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144773#M11252</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-25T23:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144774#M11253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/29431"&gt;Marcos Llobera&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for sharing the code, that helps, but I am wondering... is this really the code you used? I'm asking since lines 11, 12 and 13 are missing an indentation and line 80 still has a space between "sa." and "CostPath".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will really be necessary to have access to the data you are using, in the first place to help understand the code and in the second place to see if strange behavior might be related to the data.It is weird though that running the same code on the same data has different results (crashes).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;&amp;nbsp;, don't go, you will miss out on all the fun.&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/confused.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 02:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144774#M11253</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-10-26T02:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144775#M11254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And, please a full description of the input Dem. Is it in projected space?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 06:33:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144775#M11254</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2017-10-26T06:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144776#M11255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When pasting the code all indentation was lost. So I manually had to indent using spaces. I am happy to share the data (it is just for testing) but I am not familiar with the procedure to&amp;nbsp;post it. If you let me know how to do that I will.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 16:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144776#M11255</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-26T16:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144777#M11256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/xander_bakker"&gt;xander_bakker&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;Found how to post the data. So, you should have everything to run. Let me know if there is anything else.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 17:01:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144777#M11256</guid>
      <dc:creator>MLLO</dc:creator>
      <dc:date>2017-10-26T17:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144778#M11257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/29431"&gt;M LLO&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should open the thread:&amp;nbsp;&lt;A href="https://community.esri.com/thread/204140"&gt;Path Distance erratic and crashes in a loop&lt;/A&gt;&amp;nbsp; and when you&amp;nbsp;create a comment you will see in the upper right corner the link "use advanced editor":&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/381472_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the advanced editor in the lower left corner you will find a link to attach data to the thread:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/381491_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 17:03:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144778#M11257</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-10-26T17:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144779#M11258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;&lt;STRONG&gt;Code formatting.... the basics++&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp; python obviously, to get syntax and highlighting right&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 17:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144779#M11258</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-10-26T17:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Path Distance erratic and crashes in a loop</title>
      <link>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144780#M11259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I tried to run the code and a number of errors occurred. The first one was with the Focal Statistics using the weight kernel&amp;nbsp;from the file EXPD.TXT. Although it seems perfectly OK, it throws an error:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/381507_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;To be sure it wasn't any problem with the path I changed the location of the file, but with no luck:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/381508_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;The overwrite setting is not working very well, since when running the code again it tells me this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/381542_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;I had to close my IDE to be able to delete the previous files. So I decided to throw in a different Focal Statistics operation, which is obviously not the same, but something the allows the code to continue:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;rPthPot &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FocalStatistics&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rGt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;NbrCircle&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;20&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'CELL'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'MEAN'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'DATA'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&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;The additional DATA parameter might be good to include in your code to reduce NoData values in the output. After this the&amp;nbsp;code continued, but returned another error:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-4" src="https://community.esri.com/legacyfs/online/381543_pastedImage_4.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While inspecting "rPthPot.maximum" I noticed that the entire raster contains NoData values. So I went back and tried to trace where that&amp;nbsp;raster is based on. When I look at this parte of the code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rG0 &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; rGt_1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; wFactor&amp;nbsp; &lt;SPAN class="comment token"&gt;# (0 - 0) * 0.2 = 0&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rMark &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rPath &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rGt_1 &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rGmax&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; I&amp;nbsp; &lt;SPAN class="comment token"&gt;# 1 * (1-(0/5)) * 4 = 4 or 0&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rGt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rGt_1 &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rW &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rMark&amp;nbsp; &lt;SPAN class="comment token"&gt;# 0 + 0 + 4 or 0 = 4 o 0&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rGt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'rGt.tif'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can see that rW is always 0 and rGt_1 is 0, so rGt is actually rMark and that raster contains value 4 for the route and value 0 for all other pixels. When this raster is used in the calculation it yields an error since it expects a raster or layer and None does not comply to that, since&amp;nbsp;rPthPot.maximum is None.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I switch off that part in case the&amp;nbsp;rPthPot.maximum is None and let the code run again and this time it finished the first iteration but came up with this error:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-5 jive-image" src="https://community.esri.com/legacyfs/online/381544_pastedImage_5.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The raster contains all NoData cells and can't be used for the Path Distance. So maybe you can functionally describe what you are trying to do, since there are a number of things in the code that don't make sense to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:55:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/path-distance-erratic-and-crashes-in-a-loop/m-p/144780#M11259</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T07:55:28Z</dc:date>
    </item>
  </channel>
</rss>

