Calculating distance between hospitals vs households, using previously recorded GPS coordinates, kept in CSV

Dear Kobo Team,

Is it possible to Calculate the distance between hospitals vs households, using previously recorded GPD coordinate, When enumerator reaches a household must take GPs coordinates and then kobo can use pull function to retrieve the hospitals coordinates captured before and calculate distance and let enumerator know the distance from household to the hospital

You can calculate the distance between 2 locations (actually, geopoints) using a simple calculation and the existing ODK distance() function. There’s already a good ODK forum post about this, so I wont repeat it again here: Calculate distance between geopoints - Support - ODK Forum

In my example both locations are obtained from user input, but there is nothing to stop you getting one or both locations from external csv data sources


Dear Sir,

This one can not work in my context, since it requires checking the location on the Map or reaching both areas at the same time, suppose that you are conducting a household survey, for each household has its bank where they kept their money, you are not going to fly to take this Geopoint of the bank and come back take the geopoint from this household, but If possible to capture the Geopoints for each Bank around, during preparation, this can be used during the survey, This is how my question is.

As noted, you can acquire either of the two locations - or both - by whatever means are appropriate. In your case, it sounds like you will previously determine all the locations (of the target hospitals) beforehand, and then want to determine the distance from a specific one when out in the field. If that is the case, then you can put all these predetermined locations in an external CSV dataset, and use a Select_One_from_File to pick the first location. And then use a regular Point (aka geopoint) question to capture the field location, as above.

The real ‘trick’ here is in using the distance() function and manually creating a geotrace from your 2 points using concat()

Have a play with the following form and associated CSV and see if you can adapt it to your needs.

distance_example.xlsx (5.9 KB)
mountains.csv (109 Bytes)

Thank you so much, it is working well but when I tried to compare this distance to what Google map provides,(I measured the difference using both) there is a difference, for example, google Maps showed me 7.6km while ODK distance shows me 5.8Km, between ODK and Google Map Which one is more accurate than the other?

Thank you!

What are the actual two GPS coordinates (lat, long) that you are checking?

I am using these coordinates, -1.9407287 30.0850322 1462.300048828125 12.129
I have captured them using my kobocollect app, and then I move from that place to another place to measure the distance

I mean, what are the two GPS locations that were used here, which gave you these differing results

Point A: pre-recorded location in CSV is:
Point B: taken using the Kobocollect App is:


According to this, 5.8km is correct. And I believe both Enketo and Collect use the same Great Circle algorithm to calculate distance.

Could it just be that the two markers you placed on Google Maps are a bit off?

No, for Google map, what I did was to take coordinates using WhatsApp and then send the location, When I opened the link, Google map marked 7.6km
and then I was comparing those two results.

Hi @triumvirate. The distances between this method and that of GoogleMaps will be totally different as mentioned by @Xiphware that this uses the Great Circle Algorithm. In simple terms it means that distance from Point A to Point B is measured using the shortest path and lets say this is a straight line.

On the other hand, GoogleMaps measures distances by following the route from A to B and in this case the route will have turns and curves meaning more distance between A and B (and not a straightline). Hope this simplifies the explanation. :grinning: :upside_down_face:

1 Like

Thank you for the clarification, this is helpful and it means that using ODK distance does not provide the real distance a person does to reach any place since it is linear.

1 Like