<?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: Problem with Using Python to change Travel Mode Impedance in Pro 2.5 in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176936#M1824</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I saw after I sent the email that I had replaced the square brackets by mistake.&amp;nbsp;I just tried your suggestion for the new travel mode and it worked. Thanks so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Aug 2020 19:55:09 GMT</pubDate>
    <dc:creator>jacquelinewillan1</dc:creator>
    <dc:date>2020-08-12T19:55:09Z</dc:date>
    <item>
      <title>Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176929#M1817</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;SPAN&gt;I&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;am&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;trying to test the ability to change the impedance on a TravelMode using python:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;travelModes = arcpy.nax.GetTravelModes(NDLayerName)&lt;BR /&gt;&lt;SPAN&gt;travelMode = travelModes["Travel Mode OnRoad"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;travelMode.impedance = "&lt;/SPAN&gt;&lt;SPAN&gt;Shortest&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("impedance = " + str(travelMode.impedance))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, either I am doing something wrong or&amp;nbsp;else maybe there&amp;nbsp;is a problem in Pro 2.5 with changing the impedance using python&amp;nbsp;or a problem with the impedance being held in memory?&amp;nbsp; I've tried numerous times to change the impedance without the route using the changed impedance, and then it worked.&amp;nbsp; Then when I tried to change the impedance to something else - "OnRoad', now it is stuck on "Shortest". I tried&amp;nbsp;saving the project, closing Pro, reopening Pro and the project, then&amp;nbsp; running the solve again, but with the impedance set to "OnRoad", the route being created is for the Shortest. The TravelMode actually has "OnRoad" as the impedance, so I tried deleting the line setting&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;travelMode.impedance = "&lt;/SPAN&gt;&lt;SPAN&gt;OnRoad&lt;/SPAN&gt;&lt;SPAN&gt;" (since without that, the actual TravelMode setting should be used, and the route created is still using the 'shortest' instead of OnRoad.&amp;nbsp; Any ideas what is wrong? Or is this a bug in 2.5?&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:51:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176929#M1817</guid>
      <dc:creator>jacquelinewillan1</dc:creator>
      <dc:date>2020-08-12T14:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176930#M1818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't really follow your workflow from your description, but I suggest you follow the last code sample on this page:&amp;nbsp;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/network-analyst/travelmode-nax.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/network-analyst/travelmode-nax.htm"&gt;TravelMode—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rather than editing the travel mode retrieved from the network directly, try instantiating an entirely new travel mode using the network's travel mode as a template.&amp;nbsp; Then change the impedance for the new travel mode and see if that works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:58:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176930#M1818</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2020-08-12T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176931#M1819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, that is the documentation I was following to change the impedance. The one line of code:&lt;/P&gt;&lt;P&gt;travelMode.impedance = "new impedance"&lt;/P&gt;&lt;P&gt;should change the impedance according to the documentation, but when tested, it is not changing the impedance, so that appears to be a bug unless I'm missing something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I would like to try instantiating a new travel mode if that would work, but must have the syntax wrong as I get the error:&lt;/P&gt;&lt;P&gt;KeyError: '&amp;lt;Travel Mode OnRoad&amp;gt;'&lt;/P&gt;&lt;P&gt;from using this line of code:&lt;/P&gt;&lt;P&gt;travelMode = travelModes["&amp;lt;Travel Mode OnRoad&amp;gt;"]&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff; font-weight: 300;"&gt;I also tried: travelMode = travelModes({"&amp;lt;Travel Mode OnRoad&amp;gt;"})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff; font-weight: 300;"&gt;but that gave a different error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff; font-weight: 300;"&gt;Where do the &amp;lt; &amp;gt; brackets go? Thanks for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 16:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176931#M1819</guid>
      <dc:creator>jacquelinewillan1</dc:creator>
      <dc:date>2020-08-12T16:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176932#M1820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The brackets are added automatically to the name.&amp;nbsp; You don't need to do anything with those.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Get all existing travel modes from the network dataset&lt;/SPAN&gt;
travel_modes &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;nax&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetTravelModes&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;network&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Get the existing "Driving Time" travel mode to use as a template&lt;/SPAN&gt;
existing_tm &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; travel_modes&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Driving Time"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Construct a new TravelMode object from the existing travel mode&lt;/SPAN&gt;
new_travel_mode &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;nax&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TravelMode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;existing_tm&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Update the new travel mode's impedance&lt;/SPAN&gt;
new_travel_mode&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;impedance &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MyImpedance"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Use the new travel mode object when constructing a OD Cost Matrix object&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;nax&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;OriginDestinationCostMatrix&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;network&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
od_object&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;travelMode &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; new_travel_mode‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:06:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176932#M1820</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2021-12-11T09:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176933#M1821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm still not entirely sure what your workflow is, but if you're using saveAsLayerFile() and then adding the saved .lyr&amp;nbsp;file to the map and looking at the travel mode, it's possible the travel mode name displayed will be incorrect or inconsistent. That's because .lyr files are the old ArcMap layers that do not have a concept of travel mode.&amp;nbsp; I believe the settings should be consistent, but the name might be off.&amp;nbsp; I'm not really sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is why I suggest that you use the older MakeLayer, Add Locations, Solve workflow n your script. The nax solver objects just really aren't designed to work with layers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 16:54:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176933#M1821</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2020-08-12T16:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176934#M1822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at my problem. I think the new travel mode will work and I will give it a try, however before I got your response I tried adding a new travel mode to the network dataset, manually (by opening the properties of the datset), and now I get a new error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;line of code: travelMode = travelModes("OnRoad")&lt;BR /&gt;TypeError: 'dict' object is not callable&lt;/P&gt;&lt;P&gt;This is the same line of code that was giving no error before. I tried 'Build Network Dataset' to see if this would take care of the problem, but it didn't. Any thoughts? If needed I will rebuild the network again, but I was hoping there is an easier fix.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:22:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176934#M1822</guid>
      <dc:creator>jacquelinewillan1</dc:creator>
      <dc:date>2020-08-12T17:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176935#M1823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;That's because&amp;nbsp;&lt;/SPAN&gt;travelMode = travelModes("OnRoad") is a syntax error.&amp;nbsp; You need to use square brackets to retrieve an item in a dictionary.&amp;nbsp;&lt;SPAN&gt;travelMode = travelModes["OnRoad"]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:27:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176935#M1823</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2020-08-12T17:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Using Python to change Travel Mode Impedance in Pro 2.5</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176936#M1824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I saw after I sent the email that I had replaced the square brackets by mistake.&amp;nbsp;I just tried your suggestion for the new travel mode and it worked. Thanks so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2020 19:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/problem-with-using-python-to-change-travel-mode/m-p/176936#M1824</guid>
      <dc:creator>jacquelinewillan1</dc:creator>
      <dc:date>2020-08-12T19:55:09Z</dc:date>
    </item>
  </channel>
</rss>

