Select to view content in your preferred language

Calculate Z Value Using Arcade

4560
4
Jump to solution
11-16-2020 12:13 PM
JoshSaad1
Frequent Contributor

I'm working on a project to help our Stormwater division collect data for culverts and rain swails using a high-accuracy GPS.  The data will be 3D polylines.  They need to indicate the direction of flow, from the high end to the low end of the pipe.  I'm still trying to figure out how I can visually represent that, but for now I'm starting with the attribute data.

I need to calculate the difference in elevation from the start point to the end point of the line.  I found a tool called Calculate Geometry Attributes that can calculate these values, which works great, but I'd like to automate the process using an Attribute Rule in the database.

Does anyone know how to calculate the Z value of a point using ArcGIS Arcade?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Marc_Graham
Frequent Contributor

hi,

You might want to check your data then.  I just created a demo dataset in a fgdb and it worked for me. Bearing in mind this is a very simple dataset with single part polylines.

start point:

var line = Geometry($feature);
var path = line.paths[0];
var pt = path[0];
return pt.z


end point:

var line = Geometry($feature);
var path = line.paths[0];
var pt = path[-1];
return pt.z

I created three lines and calculated their geometries in fields using the gp tool, then the same using arcade.  I then added globalids and attribute rules for two new fields.  Finally I digitised two new lines connecting the start and ends of the previously created ones.  You can see the attributes were updated successfully and they match the pre-existing lines. I wanted to insert an image but apparently I don't have permission now.

Shape *Shape_Lengthnamestart_elevend_elevarc_st_elevarc_end_elevrule_st_elevrule_end_elev
Polyline Z477.593909a128.123561.531128.123561.531<Null><Null>
Polyline Z477.22298b117.70876.076117.70876.076<Null><Null>
Polyline Z388.065934c127.234166.5974127.234166.5974<Null><Null>
Polyline Z435.647143a-c<Null><Null><Null><Null>128.123566.5974
Polyline Z416.362791c-b<Null><Null><Null><Null>127.234176.076

View solution in original post

4 Replies
Marc_Graham
Frequent Contributor

Hi,

You could try starting with the logic here: https://community.esri.com/t5/arcgis-online-questions/calculate-coordinates-of-polyline-in-arcgis-on... but accessing first_point.z and last_point.z

Hope this helps.

Cheers,

Marc

0 Kudos
JoshSaad1
Frequent Contributor

Thanks, I tried that but got a null value returned.

0 Kudos
Marc_Graham
Frequent Contributor

hi,

You might want to check your data then.  I just created a demo dataset in a fgdb and it worked for me. Bearing in mind this is a very simple dataset with single part polylines.

start point:

var line = Geometry($feature);
var path = line.paths[0];
var pt = path[0];
return pt.z


end point:

var line = Geometry($feature);
var path = line.paths[0];
var pt = path[-1];
return pt.z

I created three lines and calculated their geometries in fields using the gp tool, then the same using arcade.  I then added globalids and attribute rules for two new fields.  Finally I digitised two new lines connecting the start and ends of the previously created ones.  You can see the attributes were updated successfully and they match the pre-existing lines. I wanted to insert an image but apparently I don't have permission now.

Shape *Shape_Lengthnamestart_elevend_elevarc_st_elevarc_end_elevrule_st_elevrule_end_elev
Polyline Z477.593909a128.123561.531128.123561.531<Null><Null>
Polyline Z477.22298b117.70876.076117.70876.076<Null><Null>
Polyline Z388.065934c127.234166.5974127.234166.5974<Null><Null>
Polyline Z435.647143a-c<Null><Null><Null><Null>128.123566.5974
Polyline Z416.362791c-b<Null><Null><Null><Null>127.234176.076
JoshSaad3
Emerging Contributor

Thanks, I was testing in an AGOL web map.  When I tested in Pro it worked just fine.

0 Kudos