Limiting Extent in which a Point can Exist

10-26-2017 08:14 AM
Occasional Contributor III
5 6 2,216

On occasion, you may want to limit the extent in which points can be input into a survey. This may be to simply validate the input data on initial entry, or to restrict input for functional requirements. In the attached survey, the extent has been limited to Ireland. In order to do this, there are a few things that have to be done.

1. Get Extent Values

A good way to do this is to go to your organisations settings. Go to your Organisation - Edit Settings - Map and click Choose Extent as below.

From there, you can a Draw an extent, and note down the Lat/Long values you will need to use in your survey. The values below correspond to the values used in the attached form, so you can directly replace them as necessary.

The alternative is to use the super-useful Super-Duper Extent Helper developed by Bradley Snider.

Image of Bradley Snider

2. Setup Calculations in Survey123 Connect

There are various calculations you have to make in order to limit and input point to a particular extent, as below.

  • pulldata("@geopoint",${Location},"x")
    • This pulls the x attribute from the ${Location} geopoint question and stores it as a separate attribute
    • Further information on pulling data from geopoint questions can be found in this blog post
  • pulldata("@geopoint",${Location},"y")
    • This pulls the y attribute from the ${Location} geopoint question and stores it as a separate attribute
  • if((number(${XValue}) > -10.7) and (number(${XValue}) < -5.4), 1, 0)
    • This uses the if function in order to ensure the the x attribute returned from the pulldata function is between -10.7 and -5.4. If this is true, the value of this field is equal to 1, otherwise it is equal to 0
  • if((number(${YValue}) > 51.4) and (number(${YValue}) < 55.4), 1, 0)
    • This uses the if function in order to ensure the the y attribute returned from the pulldata function is between 51.4 and 55.4. If this is true, the value of this field is equal to 1, otherwise it is equal to 0
  • int(${ValidX}) + int(${ValidY})
    • This calculation adds the values of both if calculations together

3. Setup Constraint

This is ultimately what is used to check whether the point is within the specified extent. A message is returned to the user if it is not within the appropriate extent. In order for this to pass, it's value must equal 2 (i.e. the sum of both if statements). If it is not equal to 2, it means that either the x or y attributes, or both do not lie within the specified extent.

4. Hide and Don't Store Validation Calculations

In order to hide any validation calculations, we set the field types as hidden. We also use The Power of Nothing to ensure fields are not created to store the calculation results being used as part of the point validation (see bind::esri:fieldType column).

5. Add a Note when Outside of Extent

This will help notify the user that they are outside of the allowable extent. To do this, you add a note row, along with a label - not including a name here results in a field not being created in the Feature Layer for the note. Then specify a relevant calculation so that the warning message only gets displayed when the user is outside of the allowable extent.

See the completed form below (also attached):

geopointLocationSpecify Location
hiddenXValueX Co-Ordinatepulldata("@geopoint",${Location},"x")null
hiddenYValueY Co-Ordinatepulldata("@geopoint",${Location},"y")null
hiddenValidXX Within Rangeif((number(${XValue}) > -10.7) and (number(${XValue}) < -5.4), 1, 0)null
hiddenValidYY Within Rangeif((number(${YValue}) > 51.4) and (number(${YValue}) < 55.4), 1, 0)null
hiddenAllowedWithin Specified Extent?.=2Specified Location Outside of Extentint(${ValidX}) + int(${ValidY})null
note<b><center><font color="red">**** Specified Location Outside of Ireland ****</font></center></b>${Allowed} != 2

This is not currently supported in Web Forms because the pulldata() function is not supported when used against geopoint question (as documented here)

Occasional Contributor II

Great post.

I've been trying to implement the extent limitation for a web form, but the X,Y values are not going through? Is this not supported for the web at this time?

To be more specific, I'm testing by exposing XValue and YValue in the form, but no matter where I set the location in the map, these two values are still calculated as 0, so the message that the specified location is outside the allowed extent is always displaying. 

I'm using Chrome and have cleared the browser.

Occasional Contributor III

Hi Javier,

Glad you found it useful! As you have encountered, this is not currently possible within the web browser just yet.


Occasional Contributor III

Hi Javier,

Following on from my last comment, specifically the pulldata() function is not supported if used against a geopoint question within Web Forms - see documentation here. I have just added a note to the blog post mentioning this.


Occasional Contributor II

Wonderful Mikie.

I've check the latest updates and everything looks pretty exciting. I'll look forward for further updates, particularly in regards to the pulldata() function.


Occasional Contributor

Good news! The pulldata() function is actually now supported in webforms for the geopoint! Not sure when this enhancement was implemented but I tested this out successfully after S123 team responded to my related question about constraints on the default location:

However, there are two things that are not quite working yet to implement exactly the way Michael describes above:

1. Constraint message improperly shows OnLoad of the webform (this is supposed to be fixed by end of Feb according to post:

2.If I apply a constraint to a hidden field (e.g. Michaels "Within Specified Extent?" or my "Latitude" field). The constraint does not seem to be used by the webform and I can submit a record while violating the constraint. Once I turn this field back on (either as a note, integer or decimal), the constraint functions properly again. MY current workaround is to put the constraint into the note field that warns about the constraint (e.g. Michaels "Specified Location Outside of Ireland" note or my pic below). This is a little clunky because this shows up by default and just turns red after the user tries to submit.

Constraint message to force user to choose a location other than the default map center

Occasional Contributor

Workaround for setting geographic extent constraints in webforms is below:

First, the problem with constraint messages always showing in webforms, was resolved in v3.4 (May 2019)

Second, a constraint based on a hidden field does not seem to work in a webform (still as of v3.5)

However, my workaround to allow the webform to constrain location based on geographic extent, is to create a Notes field (with Relevant field set to only display when conditions are violated), so I am essentially following Mikie's post with addition of adding the constraint value to the note field as well as the hidden field. I'm also moving this note field to above the geopoint/map question to make it more prominent. One minor downside is that because this only works on a note field (not on hidden field), the calculation value shows up in the message (see the tiny "1" in the value below). Also this is just a bounding rectangle extent, it doesn't actually constrain observations to the exact boundary of Washington. See below for xls and screenshot:

About the Author
Technical Sales Engineer at Esri Ireland