Select to view content in your preferred language

Field Maps Arcade Expression not grabbing geometry data

794
7
Jump to solution
05-25-2023 06:27 AM
SeanNagy1
New Contributor III

I created a new point layer in ArcGIS online and added it to a map. I want to automatically calculate the MSL vertical elevation using arcade and have done so before on other layers but for some reason the calculation doesnt work for this layer and I dont understand why. Below is a snapshot of the equation with the error message. When this work it normally displays a 0

SeanNagy1_0-1685021177939.png

 

0 Kudos
1 Solution

Accepted Solutions
SeanNagy1
New Contributor III

I figured it out. For some reason I just needed to have a single feature created and on that map and then the calculations worked. It didnt seem to want to work without a feature existing. 

View solution in original post

0 Kudos
7 Replies
DavidPike
MVP Frequent Contributor

You checked that all features have a Z value?  possibly an if/else to catch exceptions would be good practice.

0 Kudos
SeanNagy1
New Contributor III

Its a brand new layer made in ArcGIS Online and selected the geometry and Z value options. The URL shows it has both enabled

SeanNagy1_0-1685023670686.png

 

0 Kudos
jcarlson
MVP Esteemed Contributor

Seems odd, but I agree with @DavidPike  that some debugging would be helpful.

Try assigning geometry($feature) to a variable and print to the Console, like

var geom = Geometry($feature)

Console(geom, geom['z'])

Understanding what's going into the rounding function will help explain why it's not returning what we want.

- Josh Carlson
Kendall County GIS
0 Kudos
SeanNagy1
New Contributor III
You will have to excuse the limits of my knowledge with coding and arcade, anyway you can write out that exact code so I can do the debugging? I'm not sure how to write it out otherwise. It is just so weird because ive used this exact process before making the layer and then using the code and never had the issue with the calculation.
0 Kudos
jcarlson
MVP Esteemed Contributor

You should be able to use the code as written. The result will show up in the Console tab of the expression builder.

- Josh Carlson
Kendall County GIS
0 Kudos
SeanNagy1
New Contributor III

I figured it out. For some reason I just needed to have a single feature created and on that map and then the calculations worked. It didnt seem to want to work without a feature existing. 

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh! Yeah, the field calculator validates the expression with a sample record from the table, and that sometimes gets weird if there are no records, or if it's validating against some outlier.

- Josh Carlson
Kendall County GIS
0 Kudos