buffering PolylineZ into PolygonZ

2382
10
11-17-2013 11:55 AM
JoeArtz
New Contributor
I have about 1000 polylineZ features that I would like to convert into polygons of a constant width, and the same length as the line.  The buffer tool created 2D, not 3D features, and the 3D Buffer tool created multipatch features.  When viewed in ArcScene, I would like the features to look like the polylines, only with width, and no thickness.  Ideas? Thanks!
0 Kudos
10 Replies
JakeSkinner
Esri Esteemed Contributor
For your polylineZ features, is each vertex the same elevation?  For example, feature 1 has an elevation of 10 feet for each vertex, feature 2 has an eleavtion of 20, etc.
0 Kudos
JoeArtz
New Contributor
Yes, each vertex has its own Z value. There are 2-4 vertices per feature, and they are relatively straight (a few bends, but nothing even close to closed or even semi closed loop).
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Joe,

The following workflow should work:

1.  Add a field of type Double called 'Elevation' to your lines feature class
2.  Right-click on the field > Calculate Geometry > Max (or Min) Z of Geometry
3.  Run the standard 'Buffer' tool on the lines feature class.  Before executing the tool, be sure to go to the Environment Settings > Z values > 'Enable' Output has Z values
4.  The output will contain the 'Elevation' field.  Using the below python code, you can iterate through each polygon and adjust the Z value using this field's value:

import arcpy
from arcpy import env
env.overwriteOutput = 1
env.workspace = r"C:\Default.gdb"

fc = "lines_buffer"

with arcpy.da.SearchCursor(fc, ["Elevation"]) as cursor:
   for row in cursor:
      vertexElevation = row[0]
      arcpy.MakeFeatureLayer_management(fc, "lines_lyr", "Elevation = " + str(vertexElevation))
      arcpy.Adjust3DZ_management("lines_lyr", "NO_REVERSE", vertexElevation)
0 Kudos
JoeArtz
New Contributor
Jake:
I will try that!  And also learn some Python at the same time!  Thanks, I'll let you know how it works.
0 Kudos
JoeArtz
New Contributor
Thanks again for your assistance, Jake.   I followed the process you outlined, and the python script ran without error, but I did not get an output file with the new 3D features.  Would the output from the script have been a new feature class, or would it have updated the input lines_buffer feature class? 

Also, I assumed that the "r" after the equal sign in the line env.workspace = r"C:\Default.gdb" is a typo?

I added and populated the Elevation field, and then ran the Buffer tool, with Z enabled as an environment variable.  The resultant polygons, however, do not have Z values. when one is edited, the sketch properties show 0 for all vertices.   The line_lyr feature class was empty at the conclusion of running the script.

One thing I haven't mentioned is that although the polylines do not overlap in 3D space, there is a great deal of overlapping in 2D.  Also, the map units for the polylines are in meters, but I buffered them to only 0.005 m (5 mm, for a total polygon width of 1 cm, because they represent bones from an archaeological site).  Would either of these "strangenesses" cause trouble for the script and the ArcTools it uses?

Thanks
Joe







Hi Joe,

The following workflow should work:

1.  Add a field of type Double called 'Elevation' to your lines feature class
2.  Right-click on the field > Calculate Geometry > Max (or Min) Z of Geometry
3.  Run the standard 'Buffer' tool on the lines feature class.  Before executing the tool, be sure to go to the Environment Settings > Z values > 'Enable' Output has Z values
4.  The output will contain the 'Elevation' field.  Using the below python code, you can iterate through each polygon and adjust the Z value using this field's value:

import arcpy
from arcpy import env
env.overwriteOutput = 1
env.workspace = r"C:\Default.gdb"

fc = "lines_buffer"

with arcpy.da.SearchCursor(fc, ["Elevation"]) as cursor:
   for row in cursor:
      vertexElevation = row[0]
      arcpy.MakeFeatureLayer_management(fc, "lines_lyr", "Elevation = " + str(vertexElevation))
      arcpy.Adjust3DZ_management("lines_lyr", "NO_REVERSE", vertexElevation)
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Joe,

No, the 'r' after the = sign for the env.workspace is not a typo.  See here for an explanation.

The script will update the original feature class.  Would you be able to zip and upload a small sample of your data?
0 Kudos
JoeArtz
New Contributor
Sure!  Here's a sample.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Joe,

The end result will not be what you are looking for.  The workflow I provided will only work when the vertices Z values are the same for each line segment.  For example, segment one has two vertices and each have an elevation of 37. 

Since each of your line's vertices are different, the buffer output will have a constant Z value for each vertex based on whether you calculated the min or max elevation for the line shapefile.  Attached are the results that you can view in ArcScene.
0 Kudos
JoeArtz
New Contributor
Jake: 

That's too bad.  Although it didn't work, I learned several things along the way. One of which would be, in the future, to include a sample of my dataset right up front. 

Thanks for your work on this, though. 

Joe
0 Kudos