Skip to content

Instantly share code, notes, and snippets.

@pbabik
Created October 28, 2016 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbabik/3ffa63db84c62218e5dfcbbecb93299e to your computer and use it in GitHub Desktop.
Save pbabik/3ffa63db84c62218e5dfcbbecb93299e to your computer and use it in GitHub Desktop.
Dashboard Cam to GeoJSON converter
#!/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