XLSForm with Mergin Maps

Not everything I do these days is with AI. Lately, I’ve had the opportunity to do some work with Mergin Maps as part of my consulting work. It is a field data collection application by Lutra Consulting that builds on top of QGIS. The mobile collection app itself is available for iOS and Android through the respective app stores.

Project authoring is done through QGIS and published from QGIS via the Mergin Maps plugin. While this requires a QGIS power user to realize its full potential, it actually makes for an otherwise lightweight experience. You can outfit a field team from your QGIS desktop, making it a fairly low barrier to entry. There is a hosted SaaS version, but you can also set it up on your own physical or cloud infrastructure, which great for data residency concerns. And, in keeping with its open source roots, the code for Mergin Maps is available on Github.

So back to the work I was doing. Without getting into the weeds about my customer’s workflow, there are instances where data gaps need to be filled with collection. The nature of those gaps can vary, especially in terms of schema, so we need to somewhat-dynamically (perhaps with AI) generate data collection forms and push them to field teams. Rather than rely on a proprietary API for this, I opted for something more open.

I collected a stop sign while walking my dog

I recalled the XLSForm format that could be used to define a form for use in ODK, Survey123, and probably other things. It’s the kind of bizarre little patch that allow humans to work in a familiar tool and ends up being more useful than you’d think. The only trouble is Mergin Maps doesn’t support XLSForm. (Could I use something else? Sure, but that’s no fun.) So a Python script was born.

I reads the .xlsx form definition, creates a QGIS project (.qgs), a geopackage with the necessary data schema, and the required form artifacts for QGIS. Once that’s done, I have a little manual work to set the project zoom and then I can sync it to Mergin Maps in the cloud and then to my device to begin collecting data. I am incrementally adding support for XLSForm features and am not close to being done with it, but I have picklists and multi-selects working pretty well.

Feel free to check out the repo and kick the tires: https://github.com/geobabbler/mergin_maps_xlsform

I also suggest checking out Mergin Maps. I’ve been impressed with it so far.