Pass Polygon coordinates to Survey123?

2323
7
08-19-2020 06:48 AM
CMcDonald
Occasional Contributor II

I have created an ArcGIS Online map that allows you to click on a Feature Layer and the Pop Up allows you to link to Survey123

Is it possible to pass the coordinates/centroid of the polygon you have selected to pass into Survey123 Data tab so that it appears as geocoded at that location instead of the Atlantic Ocean?

Thanks 🙂

0 Kudos
7 Replies
JoshuaSharp-Heward
Occasional Contributor III

Disclaimer: sourced the calculations mainly from https://community.esri.com/thread/199141-arcade-expression-for-geometry-in-arcgis-online-popup 

If you create two arcade expressions in the popup menu called lat and lon, using these arcade expressions:

var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Centroid($feature).Y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp(lat * PI / 180.0)) - PI / 2.0);

return lat
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Centroid($feature).X / originShift) * 180.0

return lon

And then at the end of the link to the survey in your popup add ?center={expression/expr0},{expression/expr1} where the first expression is the latitude and the second expression is the longitude. These expressions will calculate the long and lat in wgs84 (for using ?center= coords need to be in wgs84) of the polygon you click on in your webmap, and then pass them to a geopoint question, as described halfway through this page: https://community.esri.com/groups/survey123/blog/2019/02/06/survey123-tricks-of-the-trade-web-form-u... 

0 Kudos
CMcDonald
Occasional Contributor II

Thanks 🙂

I had some success using your solution.  The 2 Arcade expressions seem to work OK, example is the first expression

I then appended my Pop-up URL with ?center={expression/expr0},{expression/expr1}

When opening in Survey123 the behavior is a bit odd as it seems to have appended an entry with ?center

I perhaps should have said that my pop already contains

?field:site_id={SITE_ID}&field:site_name={SITE_NAME}

appended to the URL so that the Site ID and Site Name pre-populates saving the person doing the survey entering it.

So the end of my URL looks like

?field:site_id={SITE_ID}&field:site_name={SITE_NAME}?center={expression/expr0},{expression/expr1}

The red dot on the map in Survey123 Data tab still shows in the Atlantic 😞

Thanks

0 Kudos
JoshuaSharp-Heward
Occasional Contributor III

Hi,

Try adding an & between the {SITE_NAME} and ?center, like you did between the different fields you're populating earlier in the url. Currently it's reading the site_name as "{SITE_NAME}?center"

0 Kudos
CMcDonald
Occasional Contributor II

Yes! That is behaving better now 🙂

How do I get the coordinates captured to appear on the Survey123 map?

The new record still plots in the Atlantic

Thanks

0 Kudos
JoshuaSharp-Heward
Occasional Contributor III

If it's passing the coordinates correctly to the geopoint question I would think that they would be showing there in the Survey123 map! Did you confirm that on the geopoint question it was showing roughly the centrepoint of the polygon you linked from? Are you sure the point in the Atlantic isn't an older record?

0 Kudos
DavidBuehler
Occasional Contributor III

Any reason why this is not working?  I am the using the latest and greatest Survey123 version and AGOL.

 

This is what I have for my popup in AGOL.  

arcgis-survey123://?itemID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&field:parcelnumber_txt={MDLink}&field:ownername_txt={OwnerName}&field:mailingaddress_txt={OwnersMailingLabel}&field:propadd_txt={PropertyAddress}&?center={expression/expr0},{expression/expr1}

 

If it helps parcelshape_gs is the geopoint question where it should push too.

 

The expressions are the same as above.  In the popup in AGOL it shows different lat/longs for each polygon, but it does not put over to Survey123.

Thoughts?

0 Kudos
DavidBuehler
Occasional Contributor III

I figured it out:

arcgis-survey123://?itemID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&field:parcelnumber_txt={MDLink}&field:ownername_txt={OwnerName}&field:mailingaddress_txt={OwnersMailingLabel}&field:propadd_txt={PropertyAddress}&center={expression/expr0},{expression/expr1}

 

there is no need for the ? 

0 Kudos