<?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: Route solve not returning true shape in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491836#M70814</link>
    <description>&lt;P&gt;When I solve it, I'll let you know! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2024 15:22:32 GMT</pubDate>
    <dc:creator>JillianStanford</dc:creator>
    <dc:date>2024-06-13T15:22:32Z</dc:date>
    <item>
      <title>Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1486517#M70744</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I've having trouble setting the correct parameters to return a route that follows the shape of my network.&lt;/P&gt;&lt;P&gt;In the screenshot below, the thin grey lines are my road network, the green line is the shape that's generated when I solve for a route using the ArcGIS Pro tools and the purple line is the shape that's returned when I solve for the same route using the Network Analyst python module.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JillianStanford_0-1717697800246.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/106403i31B86BE64BF97922/image-size/large?v=v2&amp;amp;px=999" role="button" title="JillianStanford_0-1717697800246.png" alt="JillianStanford_0-1717697800246.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The relevant parts of my code are below. Almost all the parameters are left default, except that I've set the travel mode to "Walking" (I've tried different travel modes, they all return a funky line) and I've made sure to set the route shape type to "True Shape".&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.nax.MakeNetworkDatasetLayer(oc_network_dataset, nd_layer_name)
nd_travel_modes = arcpy.nax.GetTravelModes(nd_layer_name)
travel_mode = nd_travel_modes["Walking"]
route = arcpy.nax.Route(nd_layer_name)
route.travelMode = travel_mode
route.routeShapeType = arcpy.nax.RouteShapeType.TrueShape
stopsCur = route.insertCursor(arcpy.nax.RouteInputDataType.Stops, ["Name", "SHAPE@"], append = False)
....
stopsCur.insertRow([on_from, row2[1]])
....
stopsCur.insertRow([on_from, row3[1]])
result = route.solve()
if result.solveSucceeded:
with result.searchCursor(arcpy.nax.RouteOutputDataType.Routes, ["SHAPE@"]) as resultCursor:
    for r in resultCursor:
        insertCursor.insertRow('Routed from UL Intersection points', r[0]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a parameter on the Route that I'm missing? Or am I not handling the results correctly?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Jill&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 18:29:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1486517#M70744</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2024-06-06T18:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491058#M70808</link>
      <description>&lt;P&gt;The variables oc_network_dataset, nd_layer_name, on_from, row2, and row3 are not defined, and you need an indentation in line 14.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe,&lt;/P&gt;&lt;LI-CODE lang="python"&gt;on_from = "Stop1"
row2 = ("Stop2", arcpy.Point(1, 1))
row3 = ("Stop3", arcpy.Point(2, 2))

# Create the route object
route = arcpy.nax.Route(nd_layer_name)
route.travelMode = arcpy.nax.GetTravelModes(nd_layer_name)["Walking"]
route.routeShapeType = arcpy.nax.RouteShapeType.TrueShape

# Create an insert cursor for stops
stopsCur = route.insertCursor(arcpy.nax.RouteInputDataType.Stops, ["Name", "SHAPE@"], append=False)
stopsCur.insertRow([on_from, arcpy.PointGeometry(arcpy.Point(0, 0))])
stopsCur.insertRow([row2[0], row2[1]])
stopsCur.insertRow([row3[0], row3[1]])

# Solve the route
result = route.solve()
if result.solveSucceeded:
    with result.searchCursor(arcpy.nax.RouteOutputDataType.Routes, ["SHAPE@"]) as resultCursor:
        for r in resultCursor:
            # Assuming you have an insertCursor for the output feature class
            insertCursor.insertRow(["Routed from UL Intersection points", r[0]])&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Jun 2024 21:52:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491058#M70808</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-06-12T21:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491066#M70809</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;I just included the relevant parts of my code, not the whole thing, so those variables are defined elsewhere.&lt;/P&gt;&lt;P&gt;The code runs without error.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 22:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491066#M70809</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2024-06-12T22:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491752#M70812</link>
      <description>&lt;P&gt;So how did you solve the problem?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 14:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491752#M70812</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-06-13T14:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491836#M70814</link>
      <description>&lt;P&gt;When I solve it, I'll let you know! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 15:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1491836#M70814</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2024-06-13T15:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Route solve not returning true shape</title>
      <link>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1496130#M70902</link>
      <description>&lt;P&gt;I never did solve this problem but changed my workflow.&lt;/P&gt;&lt;P&gt;My original script looped through records, parsing a text field into two addresses, geocoding the addresses and then generating a route between them. The output was a polyline feature class of the routes.&lt;/P&gt;&lt;P&gt;What I ended up doing is modifying the script to output the addresses as points. I then import those into my route layer as stops and execute all of the routes at once using the Pro tools. All of the routes produced by this workflow follow the true shape of the road network.&lt;/P&gt;&lt;P&gt;This works for my purposes. If it comes up again and I can't work around it I will reach out to Support.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 19:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/route-solve-not-returning-true-shape/m-p/1496130#M70902</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2024-06-21T19:04:08Z</dc:date>
    </item>
  </channel>
</rss>

