Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active March 22, 2019 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/74b25ce51be8730691f27174fb3d1c55 to your computer and use it in GitHub Desktop.
Save maptastik/74b25ce51be8730691f27174fb3d1c55 to your computer and use it in GitHub Desktop.
Arcade expressions for deriving WGS84 decimal degree coordinates
// Hacky method to go from an arbitrary CRS to Spherical Mercator
var pnt3857 = Centroid(Buffer(Geometry($feature), 0.000001, 'miles'));
// Then we can just use the formulae for Spherical Mercator to WGS84
// Latitude
(2 * Atan(Exp(pnt3857.y / 6378137)) - PI / 2) / (PI / 180)
// Longitude
pnt3857.x / (PI / 180) / 6378137;
// Arcade expressions to convert point coordinates from Web Mercator to WGS84 Decimal Degrees
// Based on the LibreCalc expressions found at https://wiki.openstreetmap.org/wiki/Mercator
// Latitude
(2 * Atan(Exp(Geometry($feature).y / 6378137)) - PI / 2) / (PI / 180)
// Longitude
Geometry($feature).x / (PI / 180) / 6378137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment