5

Do you know how can I convert a google walking directions JSON response to KML?

I am using this method to get driving directions from Google in JSON format:

How can I process this and export it to KML to view it on Google Earth? Is there a Java API or something else?

Community
  • 1
  • 1
maiky
  • 3,503
  • 7
  • 28
  • 28

2 Answers2

2

I think you will be able to tackle this conversion as follows:

  1. You can parse the JSON data from Google using the org.json.JSONObject.

  2. Then to export the KML, you may want to use JAK - Java API for KML. You can also try to do this manually by following the Google KML Documentation.

Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
1

You can convert json file to kml as following

ogr2ogr -f KML /Users/Me/Documents/mydata.kml /Users/Me/Documents/mydata.json

You can also do the same from a python script:

import subprocess subprocess.call("ogr2ogr -f KML /Users/Me/Documents/mydata.kml /Users/Me/Documents/mydata.json",shell=True)

  • 1
    you really should consider improving your answer... but thanks anyway for pointing me to qgis! – cregox Aug 15 '20 at 13:05