Select to view content in your preferred language

How to batch edit Z values and set them all to zero.

912
11
Jump to solution
01-28-2025 07:56 AM
AaronManuel2
Regular Contributor

Hi, I have a line feature class with about 80k rows. It is z-enabled and some of the z values are causing extent errors, or at least I think thats whats happening. I have some vertices with a z value of 300k when they obviously shouldnt be anything near that. I'd like to edit the z-value for all vertices in this feature to 0, which is already the default value defined in our web service.

I am aware of the Adjust 3D Z tool but the problem is this tool only lets you set a relative value instead of an absolute value. If I use this tool than I can fix the vertices that have bad Zs, but the features which already have a value of 0 will be wrong. I also dont see a way to batch select vertices given a certain z value.

The other option is I can export the current record set, and disable Zs which will set them to 0. Then delete what we have in our db, and append the rows back with the 'fixed' Zs. 

Is there really no better way to do this with gp tools or arcpy? Any other solutions? Thank you.

 

1 Solution

Accepted Solutions
sjones_esriau
Esri Contributor

You can use the following arcade expression in the field calculator on the shape field.

var paths = Geometry($feature).paths
var new_paths = []
for(var p in paths) {
    var path = paths[p]
    var new_path = []
    for(var v in path) {
        var vertex = path[v]
        var new_vertex = [vertex.x, vertex.y, 0]
        Push(new_path, new_vertex)
    }
    Push(new_paths, new_path)
}
return Polyline({paths: new_paths, spatialReference: Geometry($feature).spatialReference})

View solution in original post

11 Replies
DavidSolari
MVP Regular Contributor

For a single feature, you can open the Edit Vertices tool, select one vertex in the list, hit Ctrl+A to select them all, then use the Z button to set the height for every vertex at once:

DavidSolari_0-1738082396400.png

If you have to do this for a ton of features I can't find an obvious tool for you. There's probably a way to use arcpy with Cursors and Geometry objects to write your own.

0 Kudos
AaronManuel2
Regular Contributor

Thanks. As you point out the issue is that I'm looking at doing this for a feature with thousands of records.

Maybe possible with the geometry object but I'm not seeing how to access individual vertices with any of the methods listed. Maybe with scale and setting zscale to 0.

0 Kudos
sjones_esriau
Esri Contributor

You can use the following arcade expression in the field calculator on the shape field.

var paths = Geometry($feature).paths
var new_paths = []
for(var p in paths) {
    var path = paths[p]
    var new_path = []
    for(var v in path) {
        var vertex = path[v]
        var new_vertex = [vertex.x, vertex.y, 0]
        Push(new_path, new_vertex)
    }
    Push(new_paths, new_path)
}
return Polyline({paths: new_paths, spatialReference: Geometry($feature).spatialReference})
AaronManuel2
Regular Contributor

Thank you! This worked great. I ended up having to delete some rows in our db that had null shapes also.

0 Kudos
firstNameBigganahalliPuttaswam
New Contributor

Hi. Thanks for sharing the script. This script is giving me error. Please let me know if you have any suggestions. 


ERROR 002717: Invalid Arcade expression, Arcade error: Field not found, Script line: 1
Failed to execute (CalculateField).

 Thank you.

0 Kudos
TanyaWright1
Occasional Contributor

@sjones_esriau Could you show the arcade to do this same process for a point feature?

0 Kudos
Bud
by
Esteemed Contributor
0 Kudos
Bud
by
Esteemed Contributor

I also don't see a way to batch-select vertices given a certain z value.

What kind of geodatabase and what kind of spatial type? For example, with Oracle enterprise geodatabases and the ST_GEOMETRY spatial type, you might be able to select features with certain Z values using an SQL ST_GEOMETRY function.

Edit: Maybe Calculate Geometry or Calculate Geometry Attributes could be used to put the Z values in a temporary field so that you could query them.

0 Kudos
AaronManuel2
Regular Contributor

Thanks Bud. I ended up using the arcade code from sjones_esriau. We are running postgresql 12.18.

I found out also we had quite a few rows in our database with null shape values. After deleting these I was able to run the arcade in field calculator to reset the z values. I'd be open to doing this on the postgresql side since it would be much faster.

0 Kudos