1

Working with ArcGIS Pro 2.2, I have to create a 3D polyline from array of XYZ coordinates.

When I try this code snippet :

array = arcpy.Array([arcpy.Point(0, 0, 0),arcpy.Point(0, 100, -1000)])
polyline = arcpy.Polyline(array, has_z=True)

I get an error saying that has_z is read-only:

AttributeError: DescribeGeometry: Read-only attribute has_z

From the docs it really does not seem so.

When I try not to specify the has_z parameter:

array = arcpy.Array([arcpy.Point(0, 0, 0),arcpy.Point(0, 100, -1000)])
polyline = arcpy.Polyline(array)

I receive no errors but the Polyline defaults to hasz=False as it has to.

Doing polyline.firstPoint confirms this:

<Point (0.0, 0.0, #, #)>

Is there another legit way to do it?

It seems wrong to me that has_z parameter is read-only.

2

Ok, I made it myself. I think this is a bug probably.

Using positional parameters rather than name parameters, there's no error. This is the code I succesfully used to create a 3D polyline, hope it helps. I'll probably report this to Esri.

array = arcpy.Array([arcpy.Point(0, 0, 0),arcpy.Point(0, 100, -1000)])
polyline = arcpy.Polyline(array, None, True)
polyline.firstPoint
>>> <Point (0.0, 0.0, 0.0, #)> #CORRECT!

EDIT

Here is the link to the GeoNet thread I opened.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.