Designing An OpenTrails Compatible App
We recently received an inquiry from our friends at Code For America who suggested designing an app for documenting trailhead information which would be compatible with their new Open Trail System Specification. The OpenTrails initiative seeks to “provide a uniform exchange format for publishing machine readable data on the extent, attributes, and use of our nation’s trail systems”. The goal is to help facilitate the open exchange and use of trail data between various stakeholders, including data stewards, trail managers, government agencies, and public users.
A Modern, Logical Specification
According to the documentation, the OpenTrails specification is “designed to provide a wieldy format for web and application developers”. The spec includes detailed data schemas for Trail Segments, Trailheads, and Administrative Areas. GeoJSON is the required format for spatial data while non-spatial data (lookup tables for Stewards and Named Trails) should be stored in CSV files.
While CFA is working on developing a suite of tools for converting existing trail data shapefiles into OpenTrails compliant files, many municipalities and park governments lack good trailhead data to begin with. This is a perfect use case for Fulcrum!
From Spec to App
With such a well-defined specification, building the app in Fulcrum literally took about 15 minutes.
- The Trail ID’s multiple choice field pulls values from a Named Trails choice list, which contains the name and id fields imported from the standard named_trails.csv file.
- The Trail Steward single choice field pulls values from a Stewards choice list, which contains the name and id fields imported from the standard stewards.csv file.
- The OSM Tag key-value pairs are handled by nesting a classification set inside a repeatable field. The classification set includes a key-value hierarchy of recommended osm tags.
Post-processing Fulcrum Exports
This app allows us to collect all the information required, but the Fulcrum export still requires some minimal processing in order to generate the proper trailheads.geojson file per the spec. This post-processing can easily be accomplished using the excellent ogr2ogr utility, which is part of the open source Geospatial Data Abstraction Library (GDAL). Basically, we need to join the osm_tags table and replace commas with semicolons. I’ve outlined the post-processing steps in the following bash script to help automate this task.
This exercise demonstrates the power of integrating well-defined, easily-accessible open data specifications with Fulcrum’s ability to quickly build highly-customizable data collection apps. The OpenTrails Trailheads app is up on the App Gallery and available for you to start collecting data today.