Survey123 with Collector: set geopoint

9623
27
01-13-2017 02:47 AM
Nicole_Ueberschär
Esri Regular Contributor

Hey folks, 

I have a polygon layer in collector to map plots and want to use Survey123 to collect more data to this plot. I managed to open my Survey out of collector with handing over the objectid of my feature to the survey so I can easily join the data later again. I was wondering if I could also hand over the coordinates of the centroid of my polygon to set the geopoint of my survey to have also the survey data in the correct place. 

0 Kudos
27 Replies
DougBrowning
MVP Esteemed Contributor

It is giving me a Web Mercator lat/long maybe?

I found this post in spanish  https://community.esri.com/docs/DOC-11541-crear-un-enlace-para-navegar-con-waze-en-la-ventana-emerge... 

And so i did this  Not sure if it will work in Collector though.  

var originShift = 2.0 * PI * 6378137.0 / 2.0;

var lon = (Geometry($feature).x / originShift) * 180.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, lon];

I assume all the pulldata calcs in Survey123 are WGS84 straight from the GPS right?

Thanks

JamesTedrick
Esri Esteemed Contributor

Hi Doug,

You are correct - ${feature}.x/${feature}.y Arcade expressions will produce the coordinate in the map's coordinate system (which, for the vast majority of web maps, is Web Mercator).  Either use a conversion function such as the one you have or create a web map using the WGS84 base maps to get a WGS84 coordinate.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Thanks James I got it to work ok.  For others.

I created two Arcade expressions using the code above.  This actually works in the new Collector!  So I can now launch a form and pass the WGS84 coordinates to Survey123 into a hidden field.

Then I made it cooler.  I found this post https://community.esri.com/groups/survey123/blog/2018/01/10/calculating-distances-between-multiple-g... that showed how to calc distance between 2 points.

So I have a note showing the user the lat/long they are trying to get to.  I then have the lat long of their current location shown just below the map.  I then use the distance code in a field to show the user how far in meters they are away from where they are supposed to be.  It updates automatically whenever the GPS button is hit. I then store this distance for QA later (I could constrain on that but we have rules where they can move.  I just constrain on GPS accuracy.  Even cooler you could add a field that appears based on distance - like did you need to move this plot?)

Pretty slick!  Hope someone can use it.

BTW the all in one line version to calc distance between two points is

round(acos(sin(${Northing} * pi() div 180)*sin(${DesignNorthing} * pi() div 180) + cos(${Northing} * pi() div 180)*cos(${DesignNorthing} * pi() div 180)*cos((${DesignEasting} * pi() div 180)-(${Easting} * pi() div 180))) * 6371000,2)

m3
by
Occasional Contributor II

I have done similar and to test I’m sending the x and y into plain text fields in Survey123 to verify they are correct, however the center=y,x portion of the URL isn’t overwriting my current location.  So the expression is working as in giving me the correct x, y coordinates in text but the &center=y,x is not.  

 

Any help?

0 Kudos
ChristopherKelley
New Contributor

Do you know why my location data is being truncated?  I have tried setting the geopoint in Survey 123 by passing location data with:

  • center{lat},{long}
  • passing the lat and long into new fields and calculating geopoint location
  • passing lat and long into new fields and using pulldata to set geopoint

All the methods work, but they always shorten my location data to the degree minute scale whn the original data is decimal degree to 8 decimal places.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Chris,

Can you check the attribute configuration in the pop-up settings?  Refer to step 5 in the 'Configure pop-ups' subsection of  Configure pop-ups—ArcGIS Online Help | ArcGIS 

DanteLee
Occasional Contributor II

Oy! So glad I found this comment. It was driving me nuts! lol Thanks James

0 Kudos
JoshConrad1
New Contributor III

@DougBrowning @JamesTedrick 

All:

I have been experiencing the same issues described in this thread: trying to create an attribute expression that calculates lat/long coordinates from a hosted feature layer, then integrate Field Maps with Survey123 to open a form and have the geopoint plot the submitted survey on top of the feature using the result of the attribute expression using a custom URL via the custom URL popup (&center=).

I have been using the below formula, which is called out in a multitude of other posts on the community page and it was correctly calculating the coordinates in ArcGIS Online Web Viewer Classic, but then when we tested this functionality in the field, the point was not mapping:

var originShift = 2.0 * PI * 6378137.0 / 2.0;

var lon = (Geometry($feature).x / originShift) * 180.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, lon];

I found that this formula results in an Array data type, with associated brackets. These brackets do not show up in ArcGIS Online, but when you view the popup in Field Maps, you can see the brackets. So because of this, i tested further and in the original function, i removed the brackets in the return line, which worked but was not perfect. It was not perfect because the coordinate results ended up being truncated to 2 decimals, and even though the submitted form was executing, the point was being plotted hundred of feet away.

After 10 hours of testing and researching these threads (which by the way, all of the contributions are EXPONENTIALLY HELPFUL AND I AM SO GRATEFUL OF YOUR KNOWLEDGE) i was able to find the CORRECT SOLUTION:

1.) Create an attribute expression for latitude:

var lat;
var originShift = 2.0 * PI * 6378137.0 / 2.0;

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

2.) Create an attribute expression for longitude:

var lon;
var originShift = 2.0 * PI * 6378137.0 / 2.0;

lon = number(Geometry($feature).x / originShift) * 180.0;
return lon;

3.) Because of the "number" identifier, In ArcGIS Online Web Map Viewer Classic go to Configure Popups, make sure your pop up display is custom, then the important step is to click Configure Attributes. Navigate to the newly created expressions and expand the decimal places to a minimum of 5.

4.) Lastly, in the custom URL make the "&center={expression/expr3},{expression/expr4} where expr 3 is Lat and expr 4 is Long.

I have been testing since i discovered this and it has been running smoothly. Happy Mapping!

0 Kudos