<?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: Slope of polyline - Python syntax error 000989 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732361#M56826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again. I've only just had the chance to test these changes but the code is still returning an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my current code:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/191034_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;This is the error that it is returning:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/191035_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your other point about the straight line slope. On thinking about it I do think that I will need to use the straight line slope. So I will add another field to compute the straight line distance between the first and last points and will substitute this field for SLength.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Mar 2016 10:55:57 GMT</pubDate>
    <dc:creator>CamillaRootes</dc:creator>
    <dc:date>2016-03-15T10:55:57Z</dc:date>
    <item>
      <title>Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732355#M56820</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 trying to calculate the % slope of multiple polylines in a shapefile. I am using Arc 10.1 with the basic licence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run my code in the Field Calculator I get a Python syntax error on line 3. I can't see the issue - can someone tell me where I'm going wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190407_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB - I am not sure what directions the polylines were digitised in. Hence I don't know if the last point is at the higher elevation or vice versa, which is why I am trying to return the absolute change in z value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error read out I am getting when I run the code is:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/190408_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 15:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732355#M56820</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-09T15:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732356#M56821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in your expression box, it should be !Shape! with the s capitalized.&amp;nbsp; Also check your indentation, it looks sketchy.&amp;nbsp; And you need to pass the !Slength field in as well&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 16:14:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732356#M56821</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-09T16:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732357#M56822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've made changes to the expression box and the indentation. What do you mean about passing the SLength field in? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment I'm still getting the same error, with the syntax issue still on line 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190417_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 16:59:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732357#M56822</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-09T16:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732358#M56823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just noticed the error on line 4 in the above code. Have corrected it, but it wasn't the cause of the issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 17:01:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732358#M56823</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-09T17:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732359#M56824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;GetSlopePerc(!Shape!,!SLength!) &lt;/P&gt;&lt;P&gt;def GetSlopePerc(Shape,Leng)&lt;/P&gt;&lt;P&gt;in ration change !SLength! to Leng&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 17:04:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732359#M56824</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-09T17:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732360#M56825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On a side note, I hope you are calculating values for straight lines since the formula is incorrect if it isn't.&amp;nbsp; If you want to calculate the straight line slope between the start and end points, you will also need to calculate the distance between those two points ... not using the shape length, but the actual coordinates.&amp;nbsp; If they are straight lines... never mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2016 17:07:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732360#M56825</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-09T17:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732361#M56826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again. I've only just had the chance to test these changes but the code is still returning an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my current code:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/191034_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;This is the error that it is returning:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/191035_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your other point about the straight line slope. On thinking about it I do think that I will need to use the straight line slope. So I will add another field to compute the straight line distance between the first and last points and will substitute this field for SLength.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 10:55:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732361#M56826</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-15T10:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732362#M56827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've resolved the NameError and the code is now executing. I have also computed the straight line length of the polylines sucessfully and substituted this field into the code in plac of SLength. This is my current code:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/191048_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment this is only returning a value of 0. Working through the calculation for a couple of the polylines suggests that I should be getting values other than 0. Do you have any idea why I am only getting 0 values out of this code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 11:43:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732362#M56827</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-15T11:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732363#M56828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your z values are the same.&amp;nbsp; I would calculate the value of the first and last point using &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/add-geometry-attributes.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/add-geometry-attributes.htm"&gt;Add Geometry Attributes—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt; and you could use the z values from the resultant table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 02:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732363#M56828</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-17T02:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732364#M56829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got it working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately my university is tight and will only supply me with Arc 10.1, which doesn't have the Add Geometry Attributes tool. So I used the old fashioned 'Calculate geometry' function to add start and end z values to the attribute table. However, this was returning a z value of 0 for both the start and end points of every polyline. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After a bit of snooping I discovered that the z values for the layer had somehow reset to 0. Presumably during some other processing I'd done previously. So I re-extracted correct z values from a DEM of my study area. This got 'calculate geometry' to return the right z values and meant that my slope codes worked perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the final code for percentage slope (using straight line length between the start and end points):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/191311_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here is the code I used to get slope in degrees from the percentage:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/191310_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 12:16:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732364#M56829</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-17T12:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Slope of polyline - Python syntax error 000989</title>
      <link>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732365#M56830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've written up the solution to this problem, including Field Calculator Python codes for straight line length, percentage slope and degrees slope. See this document for my write-up:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/docs/DOC-7884"&gt;Python code for straight line slope of a polyline (inc. straight line length, pecentage slope, and degrees slope)&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 12:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/slope-of-polyline-python-syntax-error-000989/m-p/732365#M56830</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2016-03-17T12:32:37Z</dc:date>
    </item>
  </channel>
</rss>

