Auto-gps implementation on ODK Collect

What is the general goal of the feature?
The goal is to have a question which fills up the GPS coordinates automatically. Mostly, this happens in the background, without the data collector's knowledge. Even the auto-gps question is supposed to be hidden.

What are some example use cases for this feature?
An important problem which managers face is that they are not sure if the data collector actually went to the proper location to do the data collection or they filled up junk data from some other location. Automatic GPS will act as deterrent and give confidence to managers that the data collected is actually clean and good quality.

What can you contribute to making this feature a reality?
I have implemented this feature on our fork of ODK Collect and would like to contribute this feature back to the community, after having appropriate discussion and taking suggestions.

Some important points about this feature:

  1. A form designer creates a question with binding "auto_gps" which has GPS data type. The question should be hidden.
  2. There are 2 ways to collect GPS - through Network and through Satellite GPS. You can choose from General settings, which method you want the app to use to collect the location. Incidentally, Network GPS gives approximate location (from cell towers), but is very fast and consumes negligible battery. Satellite GPS will give a highly accurate reading, but will consume lot of battery.
  3. If choosing Satellite GPS, there is timeout defined (in General Settings, typically defined as 30 sec). This timeout will indicate how much time the app will try to get a GPS reading. If the Satellite GPS is able to get a reading, then that reading will be recorded. If not, then the Network GPS will be filled up inside the question (as a backup).
  4. While opening the form, if Location Services is turned OFF in the phone, then the form will not open. Instead, user will be taken to Location Settings page and is also given a toast, asking the user to turn on the location. Hence, the user will not be able to access the form (with auto_gps) unless he turns on the Location services.

Some final comments:
When our funder asked me to implement this feature, I had the usual thoughts coming to my mind - this will be a big drain on the battery and will be very difficult to implement properly. But I realised that enabling Network GPS consumes little battery and gives a reasonable idea of data-collector's location. In a city like Bangalore (where I tested this app), there are good number of cell-towers which give a reasonably accurate GPS reading. Also while using Satellite GPS, GPS timeout ensures that battery drain is not too much, and if Satellite is not able to return a location within the timeout period, the Network reading is anyways filled in as backup.

Hence, I feel that if the ODK community starts using this feature for their surveys in a big way, then this feature could ensure good quality data and create really huge impact in the future.

A location preload? Sounds like a useful feature.

If the objective is auditing then gps coordinates could also be added to
the question timer log. Ie coordinates recorded with each question when
the timer log is enabled along with how long the user spent in each


That all sounds great, @Raghu_Mittal!

As @Neil_Penman mentioned, perhaps your implementation could also be used to populate the existing audit file. That would also be a big win.

The high-level description of the feature sounds really good and it would be great to keep getting feedback on that.

Could you also please link us to your forks so the devs can look at some of the implementation strategies and start thinking about how it could be integrated?

@Neil_Penman Thanks for your comment. Are you talking about the class in ODK Collect? I will definitely look into pre-loading as you suggested.

@LN Unfortunately, our fork is not available on a public repo like Github or BitBucket, so I can't directly show the implementation. Instead, I intend to implement this feature on the latest ODK Collect myself and issue a pull-request. Let me know if this makes sense.

1 Like

Waiting for this feature.

am glad to hear this.

@Raghu_Mittal .Sorry just saw
your email. No not the Activity Logger. That is I believe for application
diagnostics. The Timer Audit is implemented in Utilities/

It's great to see that this is getting so much interest! It would certainly be a very useful feature.

If I understand correctly, what you have done is an extension to the existing geopoint question type is that right? The form creator would include one or more of those questions in their form. The question would not be visible when navigating the form and the answer would be populated in the background.

Here are some questions:

  • A lot of users of ODK are in rural areas. Have you tried your current implementation in a rural area?
  • In the absense of cell towers, if GPS lock is not acquired within the timeout is the field simply left blank?
  • What happens when there are multiple of these questions in a form?
  • It's not totally clear to me what auto_gps is. Is it an attribute on the bind? What are its possible values?
  • Can you share a form that would work with your implementation?

There's more information about the audit implementation on GitHub here. As @Neil_Penman states one of the next steps on that is to add a location column(s) to get a trace of locations probably at a configurable interval in the audit file. The feature you're describing is a bit different but it would be really good if the two implementations could share some code.

@Neil_Penman Thanks Neil, for the clarification. I will look at the code for

@LN Let me explain:

  • The way this whole thing works is that there is a GPS question with binding name "auto_gps". Since I am talking about binding name and every question has a unique binding name, there can only be one question with auto-gps capability.
  • When the form is opened with auto-gps question, then the will immediately fire a GPS Task to look for GPS reading and fill this reading to the auto-gps question in the background.
  • It is recommended that this question should be hidden, but it depends on the form designer. Typically, you would like to keep this question visible if you are testing auto-gps and will always hide this question when you are using this form in deployment.

My answers to your questions, in the same order:

  • No, we haven not tested this is rural areas. Our funder is planning to deploy this in relatively remote areas, but until they do that, I have no idea how well this will work in rural areas.
  • Again, I haven't tested this scenario. My guess is that it will be left blank. I will try to test this scenario sometime soon and report back.
  • Since I am talking about using binding name which is unique, there can't be more than 1 question of this type. Even otherwise, suppose we decide to implement this in another way - like putting it as an attribute, then having multiple questions of auto-gps type makes no sense. There is only one GPS reading recorded and having multiple questions will not be of any use.
  • "auto_gps", as I already mentioned, is binding name.
  • I will share a form with auto-gps question soon.

Thanks for your questions and suggestions.

1 Like

Thanks, @Raghu_Mittal, that clears the mechanism up for me, no need for a form!

I don't believe there is any existing feature where the node name is meaningful. Perhaps this could be added as a new preload.

@LN Just need a clarification, what you mean is that you want me to populate the metadata with the GPS coordinates instead of filling up a GPS question, OR you want both - i.e. the metadata as well as a question within the form. I am personally OK with both ideas.

1 Like

Good evening,
if you allow me to get into your discussion I think Both would be very interesting ! For example, metadata to collect the prospection effort and data to locate the observation.

For those interested in the technical details of this conversation, Spec addition proposal: location preload has a proposal for the addition needed to the form specification.

If you have other comments about how it should work or the user experience, please comment here!

1 Like

+1 for the specs


+1 for the preload specs.

1 Like

Hello, sorry for the lack of activity on this feature, I have been very busy over the last 1.5 months because of change of jobs. Now, I am able to dedicate some time to finish this feature.

As of now, I have implemented the feature in the same way I described in my top post. I want to give the community something to test and give feedback on. Of course, I will change it later in accordance with what is decided for implementation. Hence, I have created an apk file and a sample form and uploaded it here for users to test auto-gps feature.

Please read the top post first. Download the attachment (.zip file) which contains the apk file and a sample form. Install the given apk and put in the sample form within the odk forms directory.

You can create your own form with question binding as "auto_gps" (make the question hidden) and use the same feature.

For Auto-gps settings, goto:
General Settings->Form management
At the bottom, you will have auto-gps settings, please change them according to need.

Please give feedback on the implementation here. (1.1 MB)

1 Like

I apologize for missing this message when you first posted it, @Raghu_Mittal! There is agreement for adding a new action to the XForms spec to support the feature. The behavior I'm imagining is that when the action is first triggered, the device will start a location request. Every time it gets a location update it will write the latest update to the node specified by ref. Once either a certain accuracy is reached (5m?) or a certain amount of time passes (20s?) the updates will stop. This could be configured at the device level which it looks like is what you've done @Raghu_Mittal.

The APK crashes on launch so I haven't been able to try your implementation, @Raghu_Mittal. Did you use a similar approach for writing the point out?

On the XLSForm side, we can start by only allowing a single GPS point collected this way and do it with a fixed type and name in the same way as other metadata:

@LN, it's strange that my apk crashes on launch. Can you try my code then? My fork of ODK Collect is on this link:
and the branch that contains my code is on "auto_gps_impl_demo1".
Using the code you should be able to generate the apk and test it. Let me know if you have any queries on my code/implementation.

1 Like

excellent, waiting for this feature.
i have read that this feature is available in surveyCTO and hope to see it in ODK