Hello All,
Thank you for your time today.
I am trying to auto-populate UTM coordinates in Field Maps. I am referencing this post:
https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/common-calculated-expressions-fo...
"Sometimes, the raw x and y location are not what you need. You might need the latitude and longitude. If your map and data are using Web Mercator Projection you can write code to calculate the latitude and longitude from the x, y meter values.
Example: I need to store the latitude and longitude values to conform to some standard data collection specification.
// Create a function to convert meters to lat, long
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
function MetersToLatLon(geometry) {
if (IsEmpty(geometry)) {
return [null, null]
}
var originShift = 2.0 * PI * 6378137.0 / 2.0
var lon = (geometry.x / originShift) * 180.0
var lat = (geometry.y / originShift) * 180.0
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0)
return [Round(lat, 6), Round(lon, 6)]
}
// Call the function and return the latitude or longitude value
MetersToLatLon(Geometry($feature))[0]
How can I adapt this script for UTM?
Thank you!