Constraining a Geopoint answer to a given area.

4116
8
Jump to solution
10-28-2022 03:23 PM
RogerAsbury
Frequent Contributor

I appear to be full of Survey123 questions lately. 🙂

Given a survey with a map that has a layer defining a service area (example below) how can you confine answers (map points) that are within that polygon shape? What if there are multiple unconnected polygons? I've seen a few answers for creating single, rectangular constraints, but can't seem to find info on polygons. And I've seen nothing on creating multiples, if you have several, unconnected, areas.

Road service areas.Road service areas.

 

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @RogerAsbury

One option would be to use the new pulldata @layer functionality we just implemented with our 3.16 release. Assuming you have a previous question that requests for the service area you can use pulldata @layer to do a point in polygon lookup and verify that the location set in the geopoint is identical to the service area selected. That way your constraint would just need to be ${questionA}=${calculationA}. 

Please see this survey for a live example: https://arcg.is/1braCn

If you select a state from the drop down list a geopoint question will then become relevant, if your geopoint location doesn't reside in the state you selected then a constraint will prevent submission, otherwise if you select the state your geopoint resides in you can submit the survey. 

Source XLSForm is attached below. 

Thank you,
Zach

View solution in original post

8 Replies
ZacharySutherby
Esri Regular Contributor

Hello @RogerAsbury

One option would be to use the new pulldata @layer functionality we just implemented with our 3.16 release. Assuming you have a previous question that requests for the service area you can use pulldata @layer to do a point in polygon lookup and verify that the location set in the geopoint is identical to the service area selected. That way your constraint would just need to be ${questionA}=${calculationA}. 

Please see this survey for a live example: https://arcg.is/1braCn

If you select a state from the drop down list a geopoint question will then become relevant, if your geopoint location doesn't reside in the state you selected then a constraint will prevent submission, otherwise if you select the state your geopoint resides in you can submit the survey. 

Source XLSForm is attached below. 

Thank you,
Zach
Tiff
by
Frequent Contributor

Hi @ZacharySutherby, thanks for this solution. I have been using it in some of my forms. I am using the exact same methodology as you, but I'm finding that the constraint text is still showing up even if the constraint is fulfilled. See example below - the point is in Maryland but you can see the red text. Note this happens occasionally. When this happens, it does not prevent submitting the form, but can cause confusion for our users which we do not want. Do you have any suggestions?

Initially I was using the USA census states layer but switched to generalized boundaries layer as yours used. I thought that resolved the issue (i.e., attribute comparison processed more quickly) but I'm still seeing the constraint text remain. 

Tiff_0-1723037667695.png

 

 

0 Kudos
RogerAsbury
Frequent Contributor

Awesome! Thanks much for pointing me that way. Been wondering this for a bit. Glad to see something was recently posted. 🙂

--
Roger Asbury
Analyst/Programmer - Fairbanks North Star Borough
0 Kudos
DougBrowning
MVP Esteemed Contributor

I have also done the low tech way.  Read the lat and long into a field using pulldata then set a constraint on those numbers. 

I also have done it where it passes in the lat/long the crews are supposed to try and get to into the form from Field Maps.  Then I use a calc to see how far their current location is from where they are supposed to be.  As they refresh the map question the distance updates.  Then I can set a constraint on that distance.  Worked out well.

0 Kudos
TeresaWhitney
Occasional Contributor

How is this done if it is only based on location and not an input question value? I used a point in the same buffer polygon to add Name value to the new point feature, but I need to constrain the point location within the same buffer polygon feature service (contains several polygons). The example shown is the functionality I need but I need help finding the right way to set it up.

AmandaBeck
Regular Contributor

Hi @TeresaWhitney 

I'm wondering if you came across any other information on how to do this. I'm working on a project where I'm hoping to implement a geopoint question that checks if the point is within a polygon on the basemap. 

Thanks in advance! 

0 Kudos
TeresaWhitney
Occasional Contributor

I did get information at the Esri users conference to make this work. It was the constraint part setup that I had been missing. 

  1. First calculate a text question to get a value from your polygon using the location
    1. https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_BB97985...
    2. https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-laye...
    3. Or you can do this calculation in web designer and then download the survey into Connect to look at the syntax
  2. In the constraint column of your geopoint question, check if the value above is empty
    1. string-length(${<myquestionNamehere>})>0
    2. Also add a constraint message
  3. For the question that is calculated with the point in poly query, set the value in appearance to hidden and the value in esriFieldType to null
JamesSerendip1
Occasional Contributor

This is the answer!  Thank you so much.  One other caveat is that the layer being accessed by the pulldata line in the constrain column must be public, or else it will not be accessible to the pulldata command.

 

0 Kudos