Last active
April 6, 2018 20:50
-
-
Save frafra/c435235fdc20864b7f664b208fda2d38 to your computer and use it in GitHub Desktop.
From GeoPaparazzi notes to OpenStreetMap through GeoJSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to export to OSM XML directly use gpap-notes2osm.sql.