Creating Polylines with Z-values very slow

457
4
07-17-2013 11:44 PM
AndreasKrueger
New Contributor
Hi,

i am creating Polylines from scrath out of X,Y,Z-Points.

I need PolylineZ. When I create Polylines using arcpy.Polyline i use the Parameter "has_z = True".

If i use this Parameter, i get PolylineZ but it works that slow that the script is un-useable for me.

Without this paramater the script works fine and fast but without having Z-values.


How can i make the script faster? Has someone an idea?

Thanks.
Andy



lineArray = arcpy.Array()
pnt = arcpy.Point()

for f in list:
pnt.X = ...
pnt.Y = ...
pnt.Z = ...
lineArray.add(pnt)
feature = arcpy.Polyline(lineArray, "None", True, False)
featureList.append(feature)
lineArray.removeAll()

cursor = arcpy.da.InsertCursor(shpname, ["SHAPE@"])

for f in featureList:
cursor.insertRow()
Tags (2)
0 Kudos
4 Replies
JamesCrandall
MVP Frequent Contributor
Not sure if this would help, but perhaps this is causing the issue?


cursor = arcpy.da.InsertCursor(shpname, ["SHAPE@"])
for f in featureList:
   cursor.insertRow()



Perhaps try:


with arcpy.da.InsertCursor(shpname, ["SHAPE@"]) as cursor:
    cursor.insertRow([featureList])

0 Kudos
AndreasKrueger
New Contributor
Hi jamesfreddyc,

thanks for your reply,

the insertCursor-function is not the time killer.

the function arcpy.Polyline() is fast fithout the Parameter "has_z"

for example:

Synatx = Polyline (inputs, {spatial_reference}, {has_z}, {has_m})

polyline = arcpy.Polyline(array)    #this one is fast as expected

polyline = arcpy.Polyline(array, <none>,  True, False)    #this one is very very very slow
0 Kudos
JamesCrandall
MVP Frequent Contributor
Hi jamesfreddyc,

thanks for your reply,

the insertCursor-function is not the time killer.

the function arcpy.Polyline() is fast fithout the Parameter "has_z"

for example:

Synatx = Polyline (inputs, {spatial_reference}, {has_z}, {has_m})

polyline = arcpy.Polyline(array)    #this one is fast as expected

polyline = arcpy.Polyline(array, <none>,  True, False)    #this one is very very very slow


Okay, perhaps this is the issue:

http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000


"...When using InsertCursor on a point feature class, creating a PointGeometry and setting it to the SHAPE@ token is a comparatively expensive operation. Instead, define the point feature using tokens such as SHAPE@XY, SHAPE@Z, and SHAPE@M for faster, more efficient access."

I will look for an example of setting SHAPE@Z
0 Kudos
KoenVolleberg
New Contributor
Hi all,
I come up with the same issue.
Anyone found a solution yet?

The last suggestion  jamesfreddyc did works for point features, not for polyline features.

Cheers, Koen
0 Kudos