Displaying the boundaries of the area where data needs to be collected.

Hello, everyone.

I need to provide volunteers with the web version of kobotoolbox with information about their location, indicating the boundaries of the area in which they should collect data offline.

When designing the form, can I upload a layer with boundaries?

In Enketo (web client) you cannot upload additional map layers - eg to draw an overlay showing the survey boundary - like you can in KoboCollect. However, what you might do instead is have a geoshape question that is already pre-filled (via a default), and suitably read-only, with your desired target area to show your data collectors where they need to go.

For example, this form displays the approximate perimeter of downtown Feilding, New Zealand:

GeoBoundary.xlsx (14.4 KB)

Note, the KoboCollect mobile app has far richer mapping capabilities, including showing additional map layers. It also has the additional capability to enforce an actual geofence on your target area, to ensure the data is in fact collected within where it should be.

1 Like

Is it possible to pre-fill the default value of a geoshape question with vertices pulled in using pulldata()? I can’t seem to pre-fill the values of the ‘geometry’ field from the csv used in pulldata().

Geoboundary_pulldata.xlsx (13.4 KB)

blocks_geom.csv (10.4 KB)

It worked when I copied and pasted the raw values of the vertices from the ‘geometry’ field of the csv used in pulldata() into the default column as you’ve done above.

My intent is to geofence plots within a repeat group based on the block boundary of the block selected from the map outside of the repeat group.

Yes, but it is a bit trickier when using pulldata() to set default values, due to the default Kobo behavior of initially validating forms when you deploy them [to make sure there are no calculation errors], but then not being able to actually run this calculation yet. To get around this you can use a trick: initiating the pulldata() as consequence of setting another field in your form via a trigger; in your case, after selecting a region from the map.

Here’s a simplified form that I think does what you are attempting to accomplish in yours:

SimpleSelectFromMap.xlsx (8.6 KB)

Initially the select_one_from_file displays a map in KoboCollect - or else just a list in Enketo Web Forms (which doesn’t support select-from-map yet) - with all my regions. When this ${region} question is answered or is changed, this initiates the trigger to cause the calculation against the my geoshape ${boundary} question to be executed, thus ‘initializing’ the geoshape to the geometry that was stored against that selected region in my external csv; in my example, these are outlines of all the islands in New Zealand. The geoshape is read-only so I cant then change it; its just there to (re)display the island I previously selected.

regions.csv (44.8 KB)

In Enketo/Web Forms:

In KoboCollect it is much the same behavior, but you get a nicer looking initial select-from-map:

Once you have the ${boundary} geoshape you can then use this elsewhere in your form, eg for your geofencing [NB. you dont actually have to have the boundary in a geoshape for geofence(); you could do it just as well with a straight calculation to pull the boundary coordinates out of the csv, and not have to worry about initializing a geoshape widget with it].

1 Like

Thank you so much!

Yes, I was able to geofence using geofence(${location},instance(‘regions’)/root/item[name=${region}]/geometry)

SimpleSelectFromMap2.xlsx (9.8 KB)

YW.

Yes, you can also use the instance() function to directly pull out data from CSV files; in your case the target boundary. It does much the same as pulldata() function, but permits even more! But writing raw XPath expressions is a bit more complicated to understand, so most folk find it easier to use pulldata().