How do I use arcade in Field Maps to get the Z values from an added point location

728
3
Jump to solution
04-29-2022 04:58 AM
Larry
by
New Contributor III

I am testing Field Maps to collect points and I want to store the GPS Elevation value in a field.

My feature class has the Z enabled.

I tried

var sGeo = Centroid($feature)
return sGeo.z

But it does not return anything on Android or IOS. I am using the latest version of Field Maps on both.

I  have also found that

var sGeo = Centroid($feature)
return sGeo.x

or

return sGeo.y

work on Android but not IOS.

Are there other functions I should be using?

Thanks

1 Solution

Accepted Solutions
by Anonymous User
Not applicable

"Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference."

This was a bug in Field Maps web, we've already fixed it internally and it should be addressed in our June release. Arcade requires the feature and map to have the same spatial reference since it doesn't have a built in projection engine. The features we queried and used as samples in the Arcade Editor were not being projected to the basemap/map spatial reference so you would see this error. By switching the basemap, the feature and map now have the same spatial reference (Web Mercator presumably) so it works

View solution in original post

0 Kudos
3 Replies
by Anonymous User
Not applicable

@Larry   This should work.

var geom = Geometry($feature)
if (!IsEmpty(geom)) {
    return geom.z
} else {
    return null
}

 

0 Kudos
Larry
by
New Contributor III

Thanks Aaron, we are close,

I am using a NAD83 UTM zone 22 base map and I get the error:

"Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference."

If I switch the base map to the ESRI  World Imagery it works fine.

 

0 Kudos
by Anonymous User
Not applicable

"Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference."

This was a bug in Field Maps web, we've already fixed it internally and it should be addressed in our June release. Arcade requires the feature and map to have the same spatial reference since it doesn't have a built in projection engine. The features we queried and used as samples in the Arcade Editor were not being projected to the basemap/map spatial reference so you would see this error. By switching the basemap, the feature and map now have the same spatial reference (Web Mercator presumably) so it works

0 Kudos