<?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: Issue with Z Values Being Zero in Polylines and Polygons in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587595#M73770</link>
    <description>&lt;P&gt;This is an easy one, you have a Z-enabled featureclass, but you aren't creating z-enabled Geometry:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;polygon = arcpy.Polygon(array_polygon, has_z=True)
polyline = arcpy.Polyline(array_polyline, has_z=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Just saw that David figured this out yesterday... Only saw one response when I clicked in -_-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2025 18:26:01 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2025-02-20T18:26:01Z</dc:date>
    <item>
      <title>Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586710#M73759</link>
      <description>&lt;P&gt;現在、ArcGIS Pro 3.3で作業しているときに問題が発生しています。具体的には、Z 値を持つポリラインとポリゴンの両方を作成しようとしていますが、フィーチャクラスへの挿入時に Z 値が 0 に設定されています。&lt;/P&gt;&lt;P&gt;以下は、私のプロセスの概要です。&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;「ExampleDatabase.gdb」という名前のファイル ジオデータベースと、Z が有効なポリライン フィーチャクラスを作成します。&lt;/LI&gt;&lt;LI&gt;指定したZ値でポリラインジオメトリを作成します。&lt;/LI&gt;&lt;LI&gt;&lt;FONT&gt;an を使用して、ポリラインをフィーチャクラスに追加します。&lt;/FONT&gt;カーソルの挿入&lt;/LI&gt;&lt;LI&gt;ポリゴン フィーチャクラスを作成する場合も同様の手順を実行しますが、Z 値が 0 に設定されている場合でも同じ問題が発生します。&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;これらの手順を実行しても、挿入されたポリラインとポリゴンの両方の Z 値は常に 0 として返されます。&lt;/P&gt;&lt;P&gt;参考までに私のコードのスニペットを次に示します。&lt;/P&gt;&lt;PRE&gt;import arcpy
import os

# Create a file geodatabase
output_folder = r"D:/temp"
gdb_name = "ExampleDatabase.gdb"
gdb_full_path = os.path.join(output_folder, gdb_name)

if not arcpy.Exists(gdb_full_path):
    arcpy.management.CreateFileGDB(out_folder_path=output_folder, out_name=gdb_name)

# Create a polyline feature class
feature_class_name_polyline = "counties_polyline"
arcpy.CreateFeatureclass_management(
    out_path=gdb_full_path,
    out_name=feature_class_name_polyline,
    geometry_type="POLYLINE",
    has_z="ENABLED"  # Enable Z values
)

# Create polyline geometry with Z values
array_polyline = arcpy.Array([arcpy.Point(1000.0, 2000.0, 50.0),
                               arcpy.Point(1500.0, 2500.0, 75.0),
                               arcpy.Point(2000.0, 3000.0, 100.0)])
polyline = arcpy.Polyline(array_polyline)

# InsertCursor to add new polyline geometry
with arcpy.da.InsertCursor(os.path.join(gdb_full_path, feature_class_name_polyline), ['SHAPE@']) as cursor:
    cursor.insertRow([polyline])

# Create a polygon feature class
feature_class_name_polygon = "counties_polygon"
arcpy.CreateFeatureclass_management(
    out_path=gdb_full_path,
    out_name=feature_class_name_polygon,
    geometry_type="POLYGON",
    has_z="ENABLED"  # Enable Z values
)

# Create polygon geometry with Z values
array_polygon = arcpy.Array([arcpy.Point(1000.0, 2000.0, 50.0),
                              arcpy.Point(1500.0, 2000.0, 50.0),
                              arcpy.Point(1500.0, 2500.0, 50.0),
                              arcpy.Point(1000.0, 2500.0, 50.0),
                              arcpy.Point(1000.0, 2000.0, 50.0)])  # Closing the polygon
polygon = arcpy.Polygon(array_polygon)

# InsertCursor to add new polygon geometry
with arcpy.da.InsertCursor(os.path.join(gdb_full_path, feature_class_name_polygon), ['SHAPE@']) as cursor:
    cursor.insertRow([polygon])

# Check Z values for polyline
with arcpy.da.SearchCursor(os.path.join(gdb_full_path, feature_class_name_polyline), ['SHAPE@']) as cursor:
    for row in cursor:
        geometry = row[0]
        for part in geometry:
            for p in part:
                print("Polyline - X:", p.X, "Y:", p.Y, "Z:", p.Z)  # Output Z values

# Check Z values for polygon
with arcpy.da.SearchCursor(os.path.join(gdb_full_path, feature_class_name_polygon), ['SHAPE@']) as cursor:
    for row in cursor:
        geometry = row[0]
        for part in geometry:
            for p in part:
                print("Polygon - X:", p.X, "Y:", p.Y, "Z:", p.Z)  # Output Z values&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;両方のフィーチャクラスが Z 値を有効にして作成されていますが、挿入されたポリラインとポリゴンの Z 値は常に 0 として報告されることを確認しました。&lt;/P&gt;&lt;P&gt;なぜこれが起こっているのかを理解するのを手伝ってくれませんか?ご指導やご提案をいただければ幸いです。&lt;/P&gt;&lt;P&gt;ご協力いただきありがとうございます!&lt;/P&gt;&lt;P&gt;よろしくお願いいたします&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 23:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586710#M73759</guid>
      <dc:creator>SononosoT</dc:creator>
      <dc:date>2025-02-18T23:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586718#M73760</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I apologize for the text being in my native language.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am currently experiencing an issue when working with ArcGIS Pro3.3. Specifically, I am trying to create both polylines and polygons with Z values, but the Z values are being set to 0 upon insertion into the feature class.&lt;/P&gt;&lt;P&gt;Here is a brief overview of my process:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have verified that both feature classes are created with Z values enabled, but the Z values of the inserted polylines and polygons are always reported as 0.&lt;/P&gt;&lt;P&gt;Could you please assist me in understanding why this might be happening? Any guidance or suggestions would be greatly appreciated.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I create a file geodatabase named "ExampleDatabase.gdb" and a polyline feature class with Z enabled.&lt;/LI&gt;&lt;LI&gt;I construct a polyline geometry with specified Z values.&lt;/LI&gt;&lt;LI&gt;I use an&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;InsertCursor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to add the polyline to the feature class.&lt;/LI&gt;&lt;LI&gt;I perform similar steps for creating a polygon feature class, but I encounter the same issue with the Z values being set to 0.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Despite following these steps, the Z values of both the inserted polylines and polygons are always returned as 0.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 00:02:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586718#M73760</guid>
      <dc:creator>SononosoT</dc:creator>
      <dc:date>2025-02-19T00:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586750#M73761</link>
      <description>&lt;P&gt;Have you tried to create a list of your poly* features, then use the Copy Features tool/function as in this blog&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/working-with-3d-and-m-aware-geometries-in-arcpy/ba-p/883981" target="_blank"&gt;Working with 3D and M-aware geometries in Arcpy - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;might be worth a shot to see if it could be an alternative to cursors.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 00:53:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1586750#M73761</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-02-19T00:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587084#M73762</link>
      <description>&lt;P&gt;You need to specify that your Polyline object is Z enabled, even if you pass in three dimensional points. This is because the third dimension could be Z values or M values. I've also added a spatial reference where necessary. Please see this corrected excerpt of your code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sr = arcpy.SpatialReference(6679)

# Create a polyline feature class
feature_class_name_polyline = "counties_polyline"
arcpy.CreateFeatureclass_management(
    out_path=gdb_full_path,
    out_name=feature_class_name_polyline,
    geometry_type="POLYLINE",
    has_z="ENABLED",  # Enable Z values
    spatial_reference=sr
)

# Create polyline geometry with Z values
array_polyline = arcpy.Array([arcpy.Point(1000.0, 2000.0, 50.0),
                               arcpy.Point(1500.0, 2500.0, 75.0),
                               arcpy.Point(2000.0, 3000.0, 100.0)])
polyline = arcpy.Polyline(array_polyline, has_z=True, spatial_reference=sr)

# InsertCursor to add new polyline geometry
with arcpy.da.InsertCursor(os.path.join(gdb_full_path, feature_class_name_polyline), ['SHAPE@']) as cursor:
    cursor.insertRow([polyline])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 17:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587084#M73762</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-02-19T17:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587153#M73763</link>
      <description>&lt;P&gt;# Create a polygon feature class&lt;BR /&gt;feature_class_name_polygon = "counties_polygon"&lt;BR /&gt;arcpy.CreateFeatureclass_management(&lt;BR /&gt;out_path=gdb_full_path,&lt;BR /&gt;out_name=feature_class_name_polygon,&lt;BR /&gt;geometry_type="POLYGON",&lt;BR /&gt;has_z="ENABLED" # Enable Z values&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was... unless the original code was edited by someone other than&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/855662"&gt;@SononosoT&lt;/a&gt;&amp;nbsp;... which it shouldn't be&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 19:32:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587153#M73763</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-02-19T19:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587164#M73764</link>
      <description>&lt;P&gt;The polyline feature class was Z-enabled but the Polyline object to insert into the feature class was not, this is what I corrected on line 17 of my listing.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 19:40:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587164#M73764</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-02-19T19:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587199#M73765</link>
      <description>&lt;P&gt;got it. but&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
array_polygon = arcpy.Array([arcpy.Point(1000.0, 2000.0, 50.0),
                              arcpy.Point(1500.0, 2000.0, 50.0),
                              arcpy.Point(1500.0, 2500.0, 50.0),
                              arcpy.Point(1000.0, 2500.0, 50.0),
                              arcpy.Point(1000.0, 2000.0, 50.0)])  # Closing the polygon
polygon = arcpy.Polygon(array_polygon)  # polygon object
out_fc = r"C:\arcpro_npg\Project_npg\npgeom.gdb\copy_poly_tst"
arcpy.CopyFeatures_management([polygon], out_fc)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="copy_poly.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/125829i99AE2567509A8077/image-size/medium?v=v2&amp;amp;px=400" role="button" title="copy_poly.png" alt="copy_poly.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;seems to work as&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;suggested back in the day&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 20:19:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587199#M73765</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-02-19T20:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587595#M73770</link>
      <description>&lt;P&gt;This is an easy one, you have a Z-enabled featureclass, but you aren't creating z-enabled Geometry:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;polygon = arcpy.Polygon(array_polygon, has_z=True)
polyline = arcpy.Polyline(array_polyline, has_z=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: Just saw that David figured this out yesterday... Only saw one response when I clicked in -_-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 18:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1587595#M73770</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-20T18:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1592101#M73864</link>
      <description>&lt;P&gt;Thank you everyone for your comments. I was able to successfully create data that includes Z values.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Added the coordinates (XYZ) to a list of tuples.&lt;/LI&gt;&lt;LI&gt;Added those coordinates to the list of tuples.&lt;/LI&gt;&lt;LI&gt;Converted each tuple to a point object and added them to a list of points.&lt;/LI&gt;&lt;LI&gt;Saved the polygons to a feature class using arcpy.CopyFeatures_management.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I was really struggling, so everyone help was truly appreciated. Thank you very much!!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 01:56:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1592101#M73864</guid>
      <dc:creator>SononosoT</dc:creator>
      <dc:date>2025-03-05T01:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Z Values Being Zero in Polylines and Polygons</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1592106#M73865</link>
      <description>&lt;P&gt;As suggested and originally posted by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Old is new &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 02:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-z-values-being-zero-in-polylines-and/m-p/1592106#M73865</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-03-05T02:35:30Z</dc:date>
    </item>
  </channel>
</rss>

