How to create 3D lines from 2D points with an elevation attribute

6023
0
10-26-2018 03:00 PM
by Anonymous User
Not applicable
1 0 6,023

These steps show how to convert 2-dimensional (2D) points into 3-dimensional (3D) ones, and how to use those points to convert 2D lines into 3D lines, given the existence of an elevation (Z) attribute within the point layer. The points and lines should have a meaningful, connective, spatial relationship. Examples include sewer manholes and sewer lines; water valves, hydrants, and water lines; street lights and underground power feed lines.

Prerequisites:

  • ArcGIS Desktop Advanced (formerly called ArcInfo)
  • 3D Analyst Extension for Desktop (extension files must be installed and then checked out in Customize > Extensions…)

For best results:

  • Single-part, 2D lines are best.  Multi-part, 2D lines can be converted to 3D, but the results need to be re-broken into parts
  • If the point layer is actually a multipoint layer, use ArcToolbox > Data Management Tools > Features > Multipart to Singlepart first, and use the resulting layer in the instructions below
  • It is desirable that the point and line feature classes share the same coordinate system, resolution, and tolerance to improve the Spatial Join step
  • These steps assume that an elevation of 0 is valid, such as sea level. If this is not the case, you should change the SQL queries below or set 0's to NULL through Field Calculator.

Notes:

  • These steps do not alter the original data
  • It is not necessary that all line vertices coincide with all points
  • It is not necessary that all points coincide with line vertices
  • It is not necessary that all of the points have a non-null, non-zero value for elevation

Tools and dialogs require input and output values. Values colored in orange reference the tutorial data. In practice, choose your own feature classes, field names, and constants. Values colored in blue are output values; you choose the name of what is created.   Blue feature classes are not included in the .zip file.   I try to use ArcToolbox throughout, so that the Geoprocessing Results window contains all steps as they were taken.   Tools that modify or create new data work off of the selected features, if any, or all features if there is no selection, so keep that in mind.

These steps were tested with ArcGIS Desktop 10.6.1, but may work in other versions as well. A downloadable .zip file contains a 10.6.1 map document with fake data in a file geodatabase to work through as a tutorial. In 10.6.1, I noticed that wizards worked all of the time, while ArcToolbox only worked most of the time. When the ArcMap UI offers a way of doing something that a Toolbox also provides, use the UI in 10.6.1.

First, create a map document containing the layers you are interested in converting, as well as a few layers for reference. Save at every meaningful point along the way.

Second, create 3D points from 2D points. This tool can be run with any level of Desktop, but requires 3D Analyst.

  • ArcToolbox > 3D Analyst Tools > Feature to 3D By Attribute
    • Input Features: MY_2D_POINTS
    • Output Feature Class: MY_3D_POINTS
    • Height Field: Z
    • To Height Field: None
    • OK

Examine the output attribute table. The SHAPE field should show "Point Z". The properties of your feature class should show "Coordinates include Z values. Used to store 3D data" as checked. All of the fields from the original 2D feature class should be intact, including names, types, aliases, widths, and domains.

Third, create a new 2D point layer whose geometry and attributes represent the vertices of the 2D lines. For example, a line with four vertices in your 2D layer will result in four point features in your output layer. Each feature will have the attributes of the line it came from.   This tool can only be run with an Advanced Desktop license, but does not require 3D Analyst.

  • ArcToolbox > Data Management Tools > Features > Feature Vertices to Points
    • Input Features: MY_2D_LINES
    • Output Feature Class: MY_2D_VERTICES
    • Point Type: ALL
    • OK

Examine the output attribute table. There will be more features in this feature class than the original, because each feature is a point representing the vertex of the original geometry. An important field in the output is ORIG_FID. This corresponds to the OBJECTID in the original 2D layer.

Fourth, find out which vertices correspond to the 3D points.   You might have 3D points match 0, 1, or more 2D vertices, and you might have 2D vertices which match 0, 1, or more 3D points. If a line's vertex matches up with more than one feature with different elevations, choose how ArcToolbox will resolve the elevation in the step marked with a * below.

  • ArcToolbox > Analysis Tools > Overlay > Spatial Join
    • Target Features: MY_2D_VERTICES
    • Join Features: MY_3D_POINTS
    • Output Feature Class: MY_2D_VERTEX _POINTS
    • Join Operation: JOIN_ONE_TO_ONE
    • Keep All Target Features: Checked
    • * Field Map of Join Features: Right-click Z > Properties… and select Mean for Merge Rule
    • Match Option: WITHIN_A_DISTANCE (or INTERSECT or ARE_IDENTICAL_TO, if your original 2D line or polygon feature vertices are all snapped to the original 2D points)
    • Search Radius (optional): Your choice. I chose 1
    • Units: Your choice.   I chose Inches
    • OK

Examine the output attribute table. Although the SHAPE is a "Point Z", the actual Z values in the feature geometry are 0.   Next, find which vertices will not have a proper elevation.

  • ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute
    • Layer Name or Table View: MY_2D_VERTEX_POINTS
    • Selection type: NEW_SELECTION
    • Expression: Join_Count = 0 OR Z IS NULL
    • OK

Examine the input attribute table. The selected features represent vertices from your 2D lines that didn't coincide with any 3D points OR coincided with points of unknown altitude. You'll notice that the elevation field for these points is <Null> which means "Unknown".

Fifth, you must make a decision as to how the original shapes will be transformed to 3D when the elevations of these vertices are missing.   Here are viable options I present to you:

Option A: Assume a flat, constant elevation value where the elevation is unknown. Edges of your resulting 3D lines will dip or rise to this constant elevation. This will help you find anomalies if you choose a very low or very high value. However, it will make your data look weird in 3D. If your data is relatively flat, this could be a good option. If you go this route, proceed to "Steps for Option A".

Option B: Assign a Z value per vertex that is the average of the other Z values in the same line. Edges of your resulting 3D lines will dip or rise moderately. However, this will give a false picture of your data in 3D space while not drawing attention to the anomalies. If you go this route, proceed to "Steps for Option B".

Option C: Do nothing and allow 3D vertices to have a 0 or NULL value. You might also choose this option if all of your vertices coincided with points of known elevation. If you go this route, proceed to "Continue".

Steps for Option A

Select all the vertices where the elevation is unknown and calculate a fixed value for those.

  • ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute
    • Layer Name or Table View: MY_2D_VERTEX_POINTS
    • Selection type: NEW_SELECTION
    • Expression: Join_Count = 0 OR Z IS NULL
    • OK
  • ArcToolbox > Data Management Tools > Fields > Calculate Field
    • Input Table: MY_2D_VERTEX_POINTS
    • Field Name: Z
    • Expression: 4300 (or the flat Z value you picked)
    • OK
  • Proceed to "Continue"

Steps for Option B

Find all the vertices where the elevation is known, and calculate an average elevation per feature.

  • ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute
    • Layer Name or Table View: MY_2D_VERTEX_POINTS
    • Selection type: NEW_SELECTION
    • Expression: Join_Count > 0 AND Z IS NOT NULL
    • OK
  • ArcToolbox > Analysis Tools > Statistics > Summary Statistics
    • Input Table: MY_2D_VERTEX_POINTS
    • Output Table: MY_AVG_LINE_Z
    • Statistics Fields: Z (MEAN)
    • Case field: ORIG_FID
    • OK
  • ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute
    • Input Table: MY_2D_VERTEX_POINTS
    • Selection type: CLEAR_SELECTION
    • OK

Join the results of the average elevation table to the vertices table by feature ID. Copy the elevation attribute over to the vertices where the vertex elevation is unknown. But before the join is performed, index important fields.

  • ArcToolbox > Data Management Tools > Indexes > Add Attribute Index
    • Input Table: MY_2D_VERTEX_POINTS
    • Fields to Index: ORIG_FID
    • Index Name: I_ORIG_FID
    • Unique: Unchecked
    • Ascending: Checked
    • OK
  • ArcToolbox > Data Management Tools > Indexes > Add Attribute Index
    • Input Table: MY_AVG_LINE_Z
    • Fields to Index: ORIG_FID
    • Index Name: I_ORIG_FID
    • Unique: Unchecked
    • Ascending: Checked
    • OK
  • ArcToolbox > Data Management Tools > Joins > Add Join
    • Layer Name or Table View: MY_2D_VERTEX_POINTS
    • Input Join Field: ORIG_FID
    • Join Table: MY_AVG_LINE_Z
    • Output Join Field: ORIG_FID
    • Keep All Target Features: Checked
    • OK
  • ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute
    • Layer Name or Table View: MY_2D_VERTEX_POINTS
    • Selection type: NEW_SELECTION
    • Expression: MY_2D_VERTEX_POINTS.Z IS NULL AND MY_AVG_LINE_Z.MEAN_Z IS NOT NULL
    • OK
  • ArcToolbox > Data Management Tools > Fields > Calculate Field
    • Input Table: MY_2D_VERTEX_POINTS
    • Field Name: Z
    • Expression: [MY_AVG_LINE_Z.MEAN_Z]
    • Expression Type: VB
    • OK
  • Remove the join (or ArcToolbox > Data Management Tools > Joins > Remove Join)
  • Proceed to "Continue" just below

Continue

  • Clear the Selection (or ArcToolbox > Data Management Tools > Layers and Table Views > Select Layer By Attribute > Selection type: CLEAR_SELECTION).

Sixth, now that the line vertices know their elevations, they can be converted to 3D points, and then stitched together into 3D lines with attributes from the original 2D lines.

  • ArcToolbox > 3D Analyst Tools > 3D Features > Feature to 3D By Attribute
    • Input Features: MY_2D_VERTEX_POINTS
    • Output Feature Class: MY_3D_VERTICES
    • Height Field: Z
    • OK
  • ArcToolbox > Data Management Tools > Features > Points to Line
    • Input Features: MY_3D_VERTICES
    • Output Feature Class: MY_3D_LINES
    • Line Field: ORIG_FID
    • Sort Field: OBJECTID
    • Close Line: Unchecked
    • OK
  • ArcToolbox > Data Management Tools > Joins > Join Field
    • Input Table: MY_3D_LINES
    • Input Join Field: ORIG_FID
    • Join Table: MY_2D_LINES
    • Output Join Field: OBJECTID
    • Join Fields: (All except OBJECTID AND Shape_Length)
    • OK
  • ArcToolbox > Data Management Tools > Fields > Delete Field
    • Input Table: MY_3D_LINES
    • Drop Field: ORIG_FID
    • OK

Now, you can delete intermediate data if you so desire. You do so at your own risk. The temporary feature classes and tables are MY_2D_VERTICES, MY_2D_VERTEX_POINTS, MY_AVG_LINE_Z, and MY_3D_VERTICES. In the future, you might be able to delete your 2D feature classes when you and your organization have migrated to using the 3D data in all applications, maps, and services.

MY_3D_POINTS and MY_3D_LINES are your final results. Add them to ArcScene to look at them in 3D.  ArcScene should be installed since you have the 3D Analyst extension. Or, add them to ArcGIS Pro with a 3D extension.

If you chose Option A, some vertices of some lines will be at the fixed elevation you chose. Some lines will be entirely at that elevation.   You should work to collect truer data at those spots to have better 3D data.

If you chose Option B, some lines will unexpectedly slope up or down to an average elevation for the feature. Some lines will be at elevation 0 or NULL. You should work to collect truer data at those spots to have better 3D data.

"Roj"

Roger Dunn

Senior GIS Programmer/Analyst

City Manager's Office/Information Technology Division

City of Orem, Utah