Arcade Expression for Geometry in ArcGIS Online Popup

15541
18
07-31-2017 08:44 AM
MaryEllen_Perko
Occasional Contributor II

Hi.  In ArcGIS Online using the web map Attribute Expressions builder, I'm trying to pull feature xy coordinates to show in a popup.  In the builder, my code successfully tests with a value; but the value in the popup and layer table is empty.  I'm using a map service if that matters.

So, is this code supposed to work?  Or am I doing something wrong?  

Thanks.

18 Replies
KevinThompson
New Contributor III

Hello Xander:

Thank you for posting this! I am wondering why my conversions are not lining up with my coordinates calculated in Arcmap. Is this the limit of this method as it is already less than 1 metre or do i need to set my Origin Shift differently perhaps?

 

X Conversion:

var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Geometry($feature).x / originShift) * 180.0;
return [lon];

 

Y Conversion:

var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Geometry($feature).y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat];

Kind Regards

XanderBakker
Esri Esteemed Contributor

The arcade expression to calculate the lat/lon values is not the most precise way of calculating the data. In addition depending on the view scale Arcade might not retrieve the exact location from the feature. The precision will do to launch navigation with Waze or open a window with Streetview, but is not the solution for an exact conversion  of the coordinates. I am still waiting for the projection engine to be implemented in Arcade to obtain more exact results. 

KevinMayall
Occasional Contributor III

Hopefully there will be a blog post when the projection engine comes to Arcade.

Kevin
0 Kudos
ANILBaral
New Contributor

Is there a way to display the location of a point in pop up using the arcade or any other way to add location in pop up along with other attributes that i get from arcade expression??

0 Kudos
XanderBakker
Esri Esteemed Contributor

Yes, you can. You can access the coordinate properties of a geometry and include those in the pop-up using Arcade. See example below:

var geom = Geometry($feature);
return "(" + Round(geom.x, 3) + ", " + Round(geom.y, 3) + ")";
0 Kudos
ANILBaral
New Contributor

i am trying to say i want to include the address of a point in a pop up using arcade(something like reverse geocode to get the address of a point as it is displayed in google map)!! i have a point layer which is editable by the user. When user adds a point i want address be displayed in the popup along with other attribute. 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Reverse geocoding is not available through Arcade.

0 Kudos
BraulioGalvez1
Esri Contributor

Hi Xander Bakker‌, Is possible do the transformation of LatLong to UTM coordinates? Or There is any code in arcade that show coordinates in UTM directly?

Best regards.

Braulio.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi/Hola Braulio Galvez ,

At this moment, only if you have a formula that allows to calculate the coordinates that you want, this is possible. As shown in the examples I shared above: https://community.esri.com/thread/199141-arcade-expression-for-geometry-in-arcgis-online-popup#comme... 

Hopefully, in the near future there will be support for a transformation engine, or what I have heard, being able to make web requests in Arcade to do this transformation using a REST call and interpret the result. This last feature is something that is on the roadmap, but I don not know the ETA.

0 Kudos