title: Plot a kml route (exported from marble) onto an openstreetmap
body: <p>I am trying to plot a route in R. The .kml file comes from Marble, a virtual globe application. It looks like this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;kml xmlns=&quot;http://earth.google.com/kml/2.2&quot; xmlns:gx=&quot;http://www.google.com/kml/ext/2.2&quot;&gt;
  &lt;Document&gt;
      &lt;visibility&gt;1&lt;/visibility&gt;
      &lt;Folder&gt;
          &lt;name&gt;Route Request&lt;/name&gt;
          &lt;visibility&gt;1&lt;/visibility&gt;
          &lt;Placemark&gt;
              &lt;name&gt;Bari&lt;/name&gt;
              &lt;visibility&gt;1&lt;/visibility&gt;
              &lt;ExtendedData&gt;
                  &lt;Data name=&quot;routingVisited&quot;&gt;
                      &lt;value&gt;false&lt;/value&gt;
                  &lt;/Data&gt;
              &lt;/ExtendedData&gt;
              &lt;Point&gt;
                  &lt;coordinates&gt;16.8511800000,41.1177300000,8.0000000000&lt;/coordinates&gt;
              &lt;/Point&gt;
          &lt;/Placemark&gt;
          &lt;Placemark&gt;
              &lt;name&gt;Trani&lt;/name&gt;
              &lt;visibility&gt;1&lt;/visibility&gt;
              &lt;ExtendedData&gt;
                  &lt;Data name=&quot;routingVisited&quot;&gt;
                      &lt;value&gt;false&lt;/value&gt;
                  &lt;/Data&gt;
              &lt;/ExtendedData&gt;
              &lt;Point&gt;
                  &lt;coordinates&gt;16.4153700000,41.2727300000,10.0000000000&lt;/coordinates&gt;
              &lt;/Point&gt;
          &lt;/Placemark&gt;
      &lt;/Folder&gt;
          &lt;Document&gt;
          &lt;name&gt;47.1 km (OSRM)&lt;/name&gt;
          &lt;visibility&gt;1&lt;/visibility&gt;
          &lt;Placemark&gt;
              &lt;name&gt;Route&lt;/name&gt;
              &lt;visibility&gt;1&lt;/visibility&gt;
              &lt;LineString&gt;
                  &lt;coordinates&gt;16.8512040000,41.1174370000 16.8508380000,41.1173690000 16.8504820000,41.1172040000 16.8494450000,41.1164640000 16.8489240000,41.1160100000 16.8488120000,41.1158720000 16.8488340000,41.1158380000 16.8513550000,41.1143390000 16.8521900000,41.1143730000 16.8524160000,41.1143590000 16.8526040000,41.1143640000 16.8526740000,41.1143290000 16.8526970000,41.1142450000 16.8528600000,41.1126580000
  …
  …
  </code></pre>
  <p>I can read the file with <code>read.OGR</code>:</p>
  <pre><code>library(rgdal)
  &gt; r1 &lt;- &quot;bari-trani.kml&quot;
  &gt; kml1 &lt;- readOGR(r1, layer = &quot;Route Request&quot;) # start and end
  OGR data source with driver: KML 
  Source: &quot;bari-trani.kml&quot;, layer: &quot;Route Request&quot;
  with 2 features and 2 fields
  Feature type: wkbPoint with 3 dimensions
  &gt; kml2 &lt;- readOGR(r1, layer = &quot;47.1 km (OSRM)&quot;) # route information
  OGR data source with driver: KML 
  Source: &quot;bari-trani.kml&quot;, layer: &quot;47.1 km (OSRM)&quot;
  with 24 features and 2 fields
  Feature type: wkbLineString with 2 dimensions
  </code></pre>
  <p>I can also plot the route:</p>
  <pre><code>&gt; plot(kml1)
  &gt; lines(kml2, col = &quot;red&quot;)
  </code></pre>
  <p><img src="https://i.stack.imgur.com/MfALi.png" alt="Route" /></p>
  <p>I have also learned how to create maps. I use the <code>Openstreetmap</code> package:</p>
  <pre><code>library(OpenStreetMap)
  &gt; topleft &lt;- c(42.08428793301783, 11.9741182832513)
  &gt; bottomright &lt;- c(37.49482899208904, 19.1591768770013)
  &gt; map &lt;- openmap(topleft, bottomright, type = &quot;osm-bw&quot;)
  &gt; plot(map)
  </code></pre>
  <p><img src="https://i.stack.imgur.com/p7EWd.png" alt="South of Italy" /></p>
  <p>However, I am unable to get the route onto the map. Plotting the route after the map does not show anything. Is there a way to do this?</p>