QuODK - another connector between ODK Central and QGIS to get your data more easily!

I have just released a new plug-in for QGIS that allows you to download data directly from ODK Central using the API… The idea is to cut out the middle-person so that people can download data without needing to log into Central, or be familiar with API scripting. This allows a QGIS user to analyse ODK data without the intervention of a Data Manager or use of a dashboard…

https://plugins.qgis.org/plugins/quodk/

So that's Qgis > yoU < ODK central (QuODK or maybe Quo DK!)

Credit where it is due, I was inspired by FooODK and have borrowed some of the basic functionality, but got carried away with adding functions for my needs!

You need access credentials for your ODK Central server before starting. These are saved (in plain text format) in the plugin’s folder. You can choose whether or not to save the password.

IMPORTANT
ODK Central Administrators might want to think about what access to provide – Data Viewer works fine, and bear in mind that this user will have access to any Projects given to that user in ODK Central. So that includes all forms within each of those projects, and all submissions within each of those forms. If you think this will / could cause a problem, please do not give ODK Central credentials to people you do not trust (or think might just be too nosey for their own good) - currently there is no way to change the data on ODK Central using this plugin, but if the data is sensitive it could be a privacy issue that you need to consider. (NOTE TO ODK CORE TEAM – this is why I would like more granular control within ODK Central for web users!)

USE
The plug-in looks a bit daunting first-time round, but hopefully if you can follow the logic, it should become fast and simple… Honestly! There is a cascade of drop-down selects to help you narrow down the submissions (and/or repeats) that would want to access. And any that have just one value become defaults to speed things up (so if you only have access to one project, it will populate the list of available forms automatically).

Here's a screenshot of the plug-in:

Once connected to the Server, select one of the project’s you have permission to access, this triggers the list of forms. On selecting a form, QGIS will connect to ODK Collect via the API and retrieve a set of submissions within the date range (and store them in memory as a dataframe). You can then filter on any attribute to narrow the range. The table is shown to help you check before loading data to the canvas.

This is an example of populated form:

The geometry column is derived from any of those in the form (shown as question name + geometry type) and you can transform the data to your preferred Projection before loading - it also appends a field called geom_from_ODK. If there is no geometry column, you can choose to load the table only. I chose to use the 'native' ODK format for geometry and convert that rather than call for WKT - this is important for my work where accuracy of data collection can be useful.

You need to load a separate layer for repeats (again with or without geometry). The relationships will be KEY / PARENT_KEY if you need to associate them (the same as CSVs downloaded directly).

These will be loaded as temporary layers in QGIS and you can export (geopackage is good!) or copy and paste the features into existing layers that have some or all of the same attributes (only those attributes in the ‘host’ layer will be pasted, which can be an advantage or a disadvantage!). Other QGIS plugins can be helpful to avoid duplicate values when appending features to existing layers, if you end up with overlapping dates (try Append Features To Layer, for example!).

If you prefer to download the data as CSV you can select that option, and depending on the geometry you can load it to the canvas (delimited text layer) – but only with lat/long (EPSG:4326) at the moment.

You can also download the attachments to a local drive. QuODK will create a new project variable called @ODK_image_path so that you can view attachments in attribute forms more easily (HINT: in QGIS use that variable as the ‘default path’ with a widget type Attachment and the relevant media type) – bear in mind that it will overwrite this Project Variable value each time you download via QuODK, so this might not be very useful if you store images in different folders for use in the same QGIS Project…

I confess that this has significantly reduced my Admin of ODK Central by allowing other team members to get their own data, and for us to grow datasets easily during data collection phases. However, it is only appropriate in teams where the data is not confidential or without restricted access - that’s beyond my pay grade and the API doesn’t currently allow those filters “upstream” as far as I know - happy to update it if there is a way to do that securely.

Plenty of scope for improvement and I’m thinking of adding Entities to the functions, but this is not imminent…Apologies for the kindergarten level python coding! Translations should be possible, but it's not a fully 'compliant' method - there are a core set of phrases in the head of the code - sort of a relic of adapting FooODK (my Swahili is not very deep!). NOTE: this does not work with any other flavour of server (e.g. Kobotoolbox) and I currently have no intention of adapting it as I would like to focus on contributing to ODK directly...

I thought this would be more useful to the ODK community than being available only to my clients…I hope it unlocks some more use cases for ODK too! The usual caveats of 'buyer beware' apply - don't hold me responsible for anything that goes wrong :slight_smile:

6 Likes

Thanks a lot Chris ! Will try it as soon as possible.