Formatting JSON file with GPS coordinates to GPX

85 views Asked by At

I have a huge JSON file with GPS coordinates which doesn't meet the typical GEOJSON format to convert it to GPX in any of the converter applications. The code looks like this:

    "eventGpx": [
      {
        "s": 1,
        "lon": 25.679939,
        "lat": 70.890846,
        "alt": 13.1,
        "dfs": 0,
        "pt": 0
      },
      {
        "s": 2,
        "lon": 25.680571,
        "lat": 70.890587,
        "alt": 10.8,
        "dfs": 0.03694342076778,
        "pt": 0
      },
      {The list goes on forever..}
}

What I want to do is to convert this to an array of only 'lon' and 'lat' meeting the GEOJSON format:

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

Any way to regex my way around this? Link to the JSON file.

0

There are 0 answers