How to generate lat/long from a UK postcode in Survey123?

652
1
Jump to solution
03-19-2021 05:31 AM
MatthewGuilliatt
New Contributor III

Hi all

I have a survey where users enter their UK postcode. I need this to be translated either to lat/long or a geopoint etc, so that it can be placed in the correct location on my feature layer.

Is this possible through calculations or other means?

1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Hi @MatthewGuilliatt 

 1.7 million post codes in the UK. This looks interesting! There are a handful of ways you can go about this:

  • pulldata CSV: This approach is best for use in the field app. It allows you to calculate a geopoint through a lookup search against a local file. It is fast and works even if disconnected from the network. To learn more about this technique, read this blog post.
  • pulldata JavaScript: This approach uses a custom JavaScript function to calculate the geopoint through a web service, such as https://postcodes.io/  This method is best if you plan to use the Survey123 web app. The pulldata CSV method will not work well on the web, because the lookup database of post codes has 1.7 million records and that would be too much to download when the web form loads. This method, as of the current 3.12 release, would require the end user to be logged-in because JavaScript functions only execute when a user is logged in. However, we are working towards enabling the use of custom JavaScript functions in public surveys in an upcoming release.
  • Automation: You could also use Survey123 Integromat or Microsoft Power Automate to perform the query against postcodes.io and then use that value to make an edit in the survey that has just been submitted. This method would work well against either the field or web apps, but the geopoint value would only be calculated once the survey is submitted.

I am assuming you need to work with postcodes (1.7M). However, if you meant postcode outcodes (roughly 3000 of them) the first method (pulldata CSV) will work well in both the web and field apps.

I found your question very interesting. I put together a blog to go into this in more detail.

View solution in original post

1 Reply
IsmaelChivite
Esri Notable Contributor

Hi @MatthewGuilliatt 

 1.7 million post codes in the UK. This looks interesting! There are a handful of ways you can go about this:

  • pulldata CSV: This approach is best for use in the field app. It allows you to calculate a geopoint through a lookup search against a local file. It is fast and works even if disconnected from the network. To learn more about this technique, read this blog post.
  • pulldata JavaScript: This approach uses a custom JavaScript function to calculate the geopoint through a web service, such as https://postcodes.io/  This method is best if you plan to use the Survey123 web app. The pulldata CSV method will not work well on the web, because the lookup database of post codes has 1.7 million records and that would be too much to download when the web form loads. This method, as of the current 3.12 release, would require the end user to be logged-in because JavaScript functions only execute when a user is logged in. However, we are working towards enabling the use of custom JavaScript functions in public surveys in an upcoming release.
  • Automation: You could also use Survey123 Integromat or Microsoft Power Automate to perform the query against postcodes.io and then use that value to make an edit in the survey that has just been submitted. This method would work well against either the field or web apps, but the geopoint value would only be calculated once the survey is submitted.

I am assuming you need to work with postcodes (1.7M). However, if you meant postcode outcodes (roughly 3000 of them) the first method (pulldata CSV) will work well in both the web and field apps.

I found your question very interesting. I put together a blog to go into this in more detail.