Calculate distance between geopoints

Hi all,

I am using ODK Collect (1.21.2) and XLS form, and I am designing a form to record locations for field collected insect samples. I'd like each new sampling location (in the same form) to be over a minimum distance from the one before it. Is it possible in the form to 1.Calculate the linear distance between sample geopoints, and 2. Have a constraint based on this minimum distance for new geopoints?

Any advice/assistance would be greatly appreciated...

If you put your two geopoints in a geotrace, you can measure the distance of the trace - ie the distance between the two locations - using the ODK distance() function.

After which you can use this value in a constraint no different than a regular constraint calculation; eg ${distance} < 100

1 Like

@Xiphware I had considered this, but the sample points need to selected independently, and there are several questions in the form related to sample collection information following the first geopoint selection, and before the selection (and geopoint) of the next sample collection location. Does that make sense?

You do not need to capture an actual geotrace per se - you can in fact construct a geotrace by simply concat'ing two (independently acquired) geopoints together, separated by a ';', eg

concat(${location1}, ';', ${location2})

Try this:

geopointdistance.xls (5.5 KB)

3 Likes

Works perfectly. Thanks @Xiphware!

Hello, i try to download the example but appear a message that the site do not exist.