<?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: ArcPy: Polyline Geomtry in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249896#M19276</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for getting back to me, your assistance is greatly appreciated. The purpose of the following script is to extract points along a polyline based on a defined user interval i.e. 100m. The polyline in this instance is a proposed pipeline (3D Polyline). I want to extract (generate) a point feature class starting at the begning of the line then thereafter every 100m in this instance ending witht the last vertex of the polyline. The newly generated (in_memory) point feature class represents the longsection of my proposed pipeline. I then extract the elevation for each point feature and export the attribute table for futher processing. What I eventually landup with is a longsection profile of my pipeline based on a user defined interval. In other words the next time round I could extract my longsection every 500m, but I need the first and last point each time. Also I can have multiple features within my feature class representing multiple pipelines that I need to generate longsection for. Please note that the longsection are plotted using a scatter graph within excel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached print screens of my polylines representing my proposed pipelines. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a note. If I run the firstPoint and lastPoint on its own it works as expected, but as soon as I combined it with positionAlongLine it seems to get confused.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2013 17:00:01 GMT</pubDate>
    <dc:creator>PeterWilson</dc:creator>
    <dc:date>2013-08-06T17:00:01Z</dc:date>
    <item>
      <title>ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249891#M19271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm busy writing a script to generate long-sections from a polyline. I've written the following based on an example from an ESRI video. The problem that I have is that the first and last position is not returned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following works but doesn't return the first and last position along the polyline:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; pts = []
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers", "SHAPE@")as rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt; row[0].length:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(i))
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 100
... arcpy.CopyFeatures_management(pts, r"in_memory\ptsalongline")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried the following but returns an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; pts = []
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers", "SHAPE@") as rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].firstPoint)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt; row[0].length:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(i))
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].lastPoint)
... arcpy.CopyFeatures_management(pts, r"in_memory\Ptsalongline")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help will be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Aug 2013 21:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249891#M19271</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-08-03T21:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249892#M19272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hmmm, I'm not sure why that doesn't work.&amp;nbsp; However, you should be able to get the first/last points using the positionAlongLine method you already have set up and simply append that to the first and last position in the point list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Didn't test this, but here's the gist I think will do it, modifying your 1st piece of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; pts = []
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers", "SHAPE@")as rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt; row[0].length:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(i))
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(row[0].length))
... arcpy.CopyFeatures_management(pts, r"in_memory\ptsalongline")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249892#M19272</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T12:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249893#M19273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the following, but unfortunately it only returns the &lt;/SPAN&gt;&lt;STRONG&gt;lastPoint&lt;/STRONG&gt;&lt;SPAN&gt; and not the &lt;/SPAN&gt;&lt;STRONG&gt;firstPoint&lt;/STRONG&gt;&lt;SPAN&gt;. Any suggestion why the following isn't working:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;pts.append(row[0].firstPoint)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 21:21:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249893#M19273</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-08-05T21:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249894#M19274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've gotten closer to what I'm looking for, but my script is currently creating the &lt;/SPAN&gt;&lt;STRONG&gt;firstPoint&lt;/STRONG&gt;&lt;SPAN&gt; multiple times until it steps outside of the while loop and then generates the &lt;/SPAN&gt;&lt;STRONG&gt;lastPoint&lt;/STRONG&gt;&lt;SPAN&gt; once. I'm not sure why suddenly the positionAlongLine is only reading the firstPoint and not the entire geometry of the polyline. Any advice in how to resolve this would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; pts = []
&amp;gt;&amp;gt;&amp;gt; with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers","SHAPE@") as rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(arcpy.PointGeometry(row[0].firstPoint))
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt; row[0].length:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(i))
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 100
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(arcpy.PointGeometry(row[0].lastPoint))
... arcpy.CopyFeatures_management(pts, r"in_memory\ptsalongline")
... del pts&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:25:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249894#M19274</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2021-12-11T12:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249895#M19275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried a projecting your data in a different coordinate system than Hatsamas_Bloukrans_3D_Albers?&amp;nbsp; (EDIT - ah, never mind, must be the name of your dataset.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not in your part of the world, so I confess I have no idea what projection this is or what your data looks like - is there any way you can attach a small sample dataset, just a few features to run test code on?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, can you describe carefully what exactly you are trying to do? -- I ask this because your loop is feeding in 100 unit increments at a time (starting at 100), so what is this really doing and is it necessary?&amp;nbsp; Verify what the units are...doesn't look like you're doing any error-trapping whatsoever, so how can you determine what is 'behaving badly'?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attach a small shapefile or something in your native projection, and someone may more likely be able to help you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 13:33:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249895#M19275</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-06T13:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Polyline Geomtry</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249896#M19276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for getting back to me, your assistance is greatly appreciated. The purpose of the following script is to extract points along a polyline based on a defined user interval i.e. 100m. The polyline in this instance is a proposed pipeline (3D Polyline). I want to extract (generate) a point feature class starting at the begning of the line then thereafter every 100m in this instance ending witht the last vertex of the polyline. The newly generated (in_memory) point feature class represents the longsection of my proposed pipeline. I then extract the elevation for each point feature and export the attribute table for futher processing. What I eventually landup with is a longsection profile of my pipeline based on a user defined interval. In other words the next time round I could extract my longsection every 500m, but I need the first and last point each time. Also I can have multiple features within my feature class representing multiple pipelines that I need to generate longsection for. Please note that the longsection are plotted using a scatter graph within excel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached print screens of my polylines representing my proposed pipelines. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a note. If I run the firstPoint and lastPoint on its own it works as expected, but as soon as I combined it with positionAlongLine it seems to get confused.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 17:00:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249896#M19276</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-08-06T17:00:01Z</dc:date>
    </item>
    <item>
      <title>Solution Found: Suspect Bug with firstPoint and lastPoint and positionAlongLine</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249897#M19277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have come up with a solution. I hope this helps anyone else that I trying to generate a means of extacting longsection from 3D Polylines for engineering purposes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm certain that there's a bug with ArcGIS when using firstPoint, lastPoint and positionAlongLine together within a for loop as the following works perfectly and is virtually the same as using firtPoint and lastPoint to derive the first and last position along a line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;pts = []
with arcpy.da.SearchCursor("Hatsamas_Bloukrans_3D_Albers","SHAPE@") as rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt; row[0].length:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leng = row[0].length
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pts.append(row[0].positionAlongLine(leng))
arcpy.CopyFeatures_management(pts, r"in_memory\ptsalongline")
del pts&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-polyline-geomtry/m-p/249897#M19277</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2021-12-11T12:25:23Z</dc:date>
    </item>
  </channel>
</rss>

