<?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: Extracting X, Y, Z from line features vertices and create a point feature class in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409661#M32303</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unfortunately it doesn't work. The feature class created already have hasZ = True. The output feature class includes X and Y coordinates as well as a column for Z-values, but that only has 0 (zero) as opposed to the correct values. When I check ptList in Python all the z-values are there, but I don't manage to get them to the feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rickard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2012 06:01:33 GMT</pubDate>
    <dc:creator>RickardHansen</dc:creator>
    <dc:date>2012-07-31T06:01:33Z</dc:date>
    <item>
      <title>Extracting X, Y, Z from line features vertices and create a point feature class</title>
      <link>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409659#M32301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to create a point feature class using vertices from a line feature class that will add the X, Y, and Z-values. I can't figure out how to get the Z-values to the point feature. I manage to get the X and Y but the Z-values always results in 0. The ptList have Z-values from the vertices but I can't get them to the point feature. I am interested in a solution using python, not using a tool like Vertices To Points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; # Set the outputZFlag environment to Enabled arcpy.env.outputZFlag = "Enabled"&amp;nbsp;&amp;nbsp; # Input feature class inFC = arcpy.GetParameterAsText(0) outFC = arcpy.GetParameterAsText(1)&amp;nbsp;&amp;nbsp; # Create describe desc = arcpy.Describe(inFC) shapefieldname = desc.ShapeFieldName inFCDataType = desc.DataType&amp;nbsp;&amp;nbsp; # Create point list ptList = []&amp;nbsp;&amp;nbsp; # Create cursor and iterate through objects in feature class rows = arcpy.SearchCursor(inFC) for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the geometry object "feat" &amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname) &amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp; # Step through each part of the feature and append vertice coordinates to point list &amp;nbsp;&amp;nbsp;&amp;nbsp; for part in feat: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part_list = [] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pnt in feat.getPart(partnum): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptList.append([pnt.X, pnt.Y, pnt.Z]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1&amp;nbsp;&amp;nbsp; # Create point object, point geometry list and iterate through list # and append every coordinate pair to geometry list.&amp;nbsp; pt = arcpy.Point() ptGeoms = [] for p in ptList: &amp;nbsp; pt.X = p[0] &amp;nbsp; pt.Y = p[1] &amp;nbsp; pt.Z = p[2] &amp;nbsp; ptGeoms.append(arcpy.PointGeometry(pt))&amp;nbsp;&amp;nbsp; # Create point feature class arcpy.management.CopyFeatures(ptGeoms, outFC)&amp;nbsp;&amp;nbsp; # Add XY to point feature class arcpy.management.AddXY(outFC)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rickard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2012 14:01:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409659#M32301</guid>
      <dc:creator>RickardHansen</dc:creator>
      <dc:date>2012-07-30T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting X, Y, Z from line features vertices and create a point feature class</title>
      <link>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409660#M32302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe you have to set hasZ:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; ...
&amp;nbsp; pt.Z = p[2]
&amp;nbsp; ptGeom = arcpy.PointGeometry(pt)
&amp;nbsp; ptGeom.hasZ = True
&amp;nbsp; ptGeoms.append(ptGeom)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not try it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409660#M32302</guid>
      <dc:creator>FabianBlau</dc:creator>
      <dc:date>2021-12-11T18:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting X, Y, Z from line features vertices and create a point feature class</title>
      <link>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409661#M32303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unfortunately it doesn't work. The feature class created already have hasZ = True. The output feature class includes X and Y coordinates as well as a column for Z-values, but that only has 0 (zero) as opposed to the correct values. When I check ptList in Python all the z-values are there, but I don't manage to get them to the feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rickard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 06:01:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409661#M32303</guid>
      <dc:creator>RickardHansen</dc:creator>
      <dc:date>2012-07-31T06:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting X, Y, Z from line features vertices and create a point feature class</title>
      <link>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409662#M32304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have found a solution that take a different perspective on the problem. In my first try I created a point object, point geometry list and iterated through list and appended every coordinate pair to geometry list. That didn't pass through the z values though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I create a table and add appropiate fields, use an insertCursor, iterate through the point list and pass X, Y and Z values in to the correct fields. From there I create an XYEvent layer and finally copy to a point feature layer. Works great!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import arcpy import arcpy&amp;nbsp; # Set the outputZFlag environment to Enabled arcpy.env.outputZFlag = "Enabled"&amp;nbsp; # Input feature class inFC = arcpy.GetParameterAsText(0) outFolder = arcpy.GetParameterAsText(1) outFC = arcpy.GetParameterAsText(2)&amp;nbsp; # Set workspace arcpy.env.workspace = outFolder&amp;nbsp; # Create describe desc = arcpy.Describe(inFC) shapefieldname = desc.ShapeFieldName inFCCoordinateSystem = desc.SpatialReference inFCDataType = desc.DataType&amp;nbsp; # Create point list ptList = []&amp;nbsp; # Create cursor and iterate through objects in feature class rows = arcpy.SearchCursor(inFC) for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the geometry object &amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname) &amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp; # Step through each part of the feature and append vertice coordinates to point list &amp;nbsp;&amp;nbsp;&amp;nbsp; for part in feat: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part_list = [] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pnt in feat.getPart(partnum): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptList.append([pnt.X, pnt.Y, pnt.Z]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1&amp;nbsp; # Create table and add fields x, y, z arcpy.management.CreateTable(outFolder, "XY_Table") arcpy.management.AddField("XY_Table", "X", "DOUBLE") arcpy.management.AddField("XY_Table", "Y", "DOUBLE") arcpy.management.AddField("XY_Table", "Z", "DOUBLE")&amp;nbsp; # Create cursor object cur = arcpy.InsertCursor("XY_Table")&amp;nbsp; # Iterate through ptList and insert a new row in table for every coordinate pair in ptList for pt in ptList: &amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.newRow() &amp;nbsp;&amp;nbsp;&amp;nbsp; row.X = pt[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; row.Y = pt[1] &amp;nbsp;&amp;nbsp;&amp;nbsp; row.Z = pt[2] &amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow(row)&amp;nbsp; # Create XY event layer arcpy.management.MakeXYEventLayer("XY_Table", "X", "Y", "XY_Table_Event") inTableEvent = "XY_Table_Event"&amp;nbsp; # Create point feature class arcpy.management.CopyFeatures(inTableEvent, outFC)&amp;nbsp; # Delete event layer and table arcpy.management.Delete(inTableEvent) arcpy.management.Delete("XY_Table")&amp;nbsp; # Create describe on out data desc2 = arcpy.Describe(outFC) outFCSpatialRef = desc2.SpatialReference outFCSpatialRefName = outFCSpatialRef.name&amp;nbsp; # Check if out data has spatial reference, # if not, project in data spatial reference on out data if outFCSpatialRefName == "Unknown": &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.DefineProjection(outFC, inFCCoordinateSystem) else: &amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 12:16:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-x-y-z-from-line-features-vertices-and/m-p/409662#M32304</guid>
      <dc:creator>RickardHansen</dc:creator>
      <dc:date>2012-08-03T12:16:48Z</dc:date>
    </item>
  </channel>
</rss>

