Select to view content in your preferred language

Lat/Long unit conversion with Arcade

19061
19
Jump to solution
10-11-2018 01:10 PM
AhjungKim4
Occasional Contributor II

I am adding geometry fields using Arcade Geometry($feature).x and Geometry($feature).y.  Since my target feature layer is in Web Mercator projection, my custom lat & long fields are displaying the values in meter.  Is there a way to convert this to decimal degrees with arcade function? 

19 Replies
AbiDhakal
Occasional Contributor III

@XanderBakker 

Hey Xander,

I have a point feature federated service in UTM NAD83 Zone16. And, I have an x and a y column that I want to populate in decimal degrees using arcade. Is it possible? What do I need to do? Here is my email address, Xander: abi.dhakal@forestry.alabama.gov

Thank you,
Abi

0 Kudos
BrittanyBurson
Regular Contributor

@XanderBakker also looking to convert from CA State plane zone 6 NAD83 into decimal degrees... all the examples I'm finding online seem to be converting from the default Web Mercator. Not sure it is possible.

MarceloCatalão
New Contributor II

hello, I tried to use this function, but it gave an error when testing, I wanted the fields of the layer to automatically have the coordinates

thanks

0 Kudos
JoseSernaUDC
New Contributor

@XanderBakker how are you determining the value "6378137.0"?

I am trying to use this NICE! Function you created but I think I am missing this portion. 

Im trying to convert x/y NAD83 New Jersey State Plane(EPSG:3424) coordinates to WGS84(EPSG:4326)

here is an example of the x/y coordinates:

x = 570384, y= 475445

I should get the following in lat/lon

-74.2201199 (long), 40.13836 (lat)

0 Kudos
AislinnCampbell
New Contributor II

Did you get a response to this or find a solution? I need the same. 

 

0 Kudos
LayerItOn
Occasional Contributor

Is there any way to make this into an attribute rule?

MarielaDel_Rio1
New Contributor

I am not entirely clear on the formula. 

I imagine the constant (6378137.0) is the semimajor axis, but why multiply by 2 and divide by 2? Doesn't that produce the same? could it be power instead of multiplication?

 

0 Kudos
TylerDeBruin
New Contributor III

Is there an arcade code similar to this to show easting/westing?

0 Kudos
RyanBohan
Regular Contributor

Thank you!  I had a Rest endpoint with only x,y in the attributes.

Your arcade worked perfectly to be able to use google directions

RyanBohan_0-1716414056025.png

var x = Geometry($feature).x
var y = Geometry($feature).y

// Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
//return [lat, lon];

var string = "https://www.google.com/maps/dir/?api=1&destination=" + lat + "," + lon + "&tavelmode=walking"
return string

 

0 Kudos
RyanBohan
Regular Contributor

It would be great to have some increased functions added to arcade to include ToLatitude(geometry($feature).x) and ToLongitude(geometry($feature).y)

Please consider adding a kudo to this idea

Covert point geometry to Latitude and Longitude - Esri Community

0 Kudos