title: Can R convert GPX files to KML files?
body: <p>There seems to be no relevant content for converting GPX to KML files. R's <code>sf</code> package can do it, if you don't care about time and elevation (I do, and that is standard in most KMLs). Does anyone know how to do this in R without downloading any other programs (like GPSbabel)?</p>
  <p>Here's a very simple example file. The metadata section is filled with link I don't totally understand, but if I leave them out, they seem to have trouble working with certain software. Could I write something myself? Yes, but I've found that there is enough variability in how gpx files present themselves that I would like to use a package that has been formally developed for this express purpose.</p>
  <p>Update: I'm attempting to do this for a track rather than track points, which is why I used a track example below.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&lt;gpx xmlns=&quot;http://www.topografix.com/GPX/1/1&quot; xmlns:gpxx=&quot;http://www.garmin.com/xmlschemas/GpxExtensions/v3&quot; xmlns:gpxtrkx=&quot;http://www.garmin.com/xmlschemas/TrackStatsExtension/v1&quot; xmlns:wptx1=&quot;http://www.garmin.com/xmlschemas/WaypointExtension/v1&quot; xmlns:gpxtpx=&quot;http://www.garmin.com/xmlschemas/TrackPointExtension/v1&quot; creator=&quot;eTrex 20x&quot; version=&quot;1.1&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackStatsExtension/v1 http://www8.garmin.com/xmlschemas/TrackStatsExtension.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd&quot;&gt;
    &lt;metadata&gt;
      &lt;link href=&quot;http://www.garmin.com&quot;&gt;
        &lt;text&gt;Garmin International&lt;/text&gt;
      &lt;/link&gt;
      &lt;time&gt;2009-10-17T22:58:43Z&lt;/time&gt;
    &lt;/metadata&gt;
    &lt;trk&gt;
      &lt;name&gt;Example GPX Document&lt;/name&gt;
      &lt;trkseg&gt;
        &lt;trkpt lat=&quot;47.644548&quot; lon=&quot;-122.326897&quot;&gt;
          &lt;ele&gt;4.46&lt;/ele&gt;
          &lt;time&gt;2009-10-17T18:37:26Z&lt;/time&gt;
        &lt;/trkpt&gt;
        &lt;trkpt lat=&quot;47.644548&quot; lon=&quot;-122.326897&quot;&gt;
          &lt;ele&gt;4.94&lt;/ele&gt;
          &lt;time&gt;2009-10-17T18:37:31Z&lt;/time&gt;
        &lt;/trkpt&gt;
        &lt;trkpt lat=&quot;47.644548&quot; lon=&quot;-122.326897&quot;&gt;
          &lt;ele&gt;6.87&lt;/ele&gt;
          &lt;time&gt;2009-10-17T18:37:34Z&lt;/time&gt;
        &lt;/trkpt&gt;
      &lt;/trkseg&gt;
    &lt;/trk&gt;
  &lt;/gpx&gt;
  
  </code></pre>