Created
October 28, 2016 13:09
-
-
Save pbabik/3ffa63db84c62218e5dfcbbecb93299e to your computer and use it in GitHub Desktop.
Dashboard Cam to GeoJSON converter
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
#!/usr/bin/python | |
import json | |
import sys | |
args = sys.argv | |
if len(args) != 3: | |
print """Usage: track2geojson.py <input>.json <output>.json""" | |
exit() | |
source = open(args[1],'rb') | |
sinkdata = {"type":"FeatureCollection", "features":[]} | |
sourcedata = json.load(source) | |
trackpoints = sourcedata['locationDatas'] | |
for trackpoint in trackpoints: | |
feature = { | |
"type":"Feature", | |
"geometry": { | |
"type":"Point", | |
"coordinates": [trackpoint['latitude'],trackpoint['longitude']], | |
}, | |
"properties": { | |
"speed": trackpoint['speed'], | |
"time": trackpoint['locationTime'] | |
} | |
} | |
sinkdata['features'].append(feature) | |
source.close() | |
with open(args[2],'wb') as sink: | |
json.dump(sinkdata, sink) | |
print "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment