Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active April 6, 2018 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/c435235fdc20864b7f664b208fda2d38 to your computer and use it in GitHub Desktop.
Save frafra/c435235fdc20864b7f664b208fda2d38 to your computer and use it in GitHub Desktop.
From GeoPaparazzi notes to OpenStreetMap through GeoJSON
/*
Description:
This query allows to convert notes from GeoPaparazzi into a GeoJSON
file that can be imported into JOSM.
Usage:
$ sqlite3 geopaparazzi.gpap < gpap-notes2geojson.sql > geopaparazzi.geojson
Made by:
Francesco Frassinelli - https://frafra.eu
*/
with osm as (
select _id,
json_group_object(
json_extract(value, '$.key'),
json_extract(value, '$.value')
) as dict
from notes,
json_each(json_extract(notes.form, '$.forms[0].formitems'))
where json_extract(value, '$.value') != ''
group by _id
)
select json_object(
'type', 'FeatureCollection',
'features', json_group_array(json_object(
'geometry', json_object(
'type', 'Point',
'coordinates', json_array(lon, lat)
),
'type', 'Feature',
'properties', json(osm.dict)
))
)
from notes
join osm
on notes._id = osm._id;
@frafra
Copy link
Author

frafra commented Feb 24, 2018

If you want to export to OSM XML directly use gpap-notes2osm.sql.

@frafra
Copy link
Author

frafra commented Apr 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment