title: How can I load multiple gpx files into PostGIS?
body: <p>I have a bunch of gpx files that come from <a href="https://github.com/mendhak/gpslogger" rel="nofollow">GPSLogger for Android</a> app.</p>
  
  <p>Files look like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;gpx  version="1.0" creator="GPSLogger - http://gpslogger.mendhak.com/"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns="http://www.topografix.com/GPX/1/0" 
    xsi:schemaLocation="http://www.topografix.com/GPX/1/0 
      http://www.topografix.com/GPX/1/0/gpx.xsd" &gt;
    &lt;time&gt;2011-08-26T06:25:20Z&lt;/time&gt;
    &lt;bounds&gt;&lt;/bounds&gt;
    &lt;trk&gt;
      &lt;trkseg&gt;
        &lt;trkpt  lat="46.94681501102746"  lon="7.398453755309032" &gt;
          &lt;ele&gt;634.0&lt;/ele&gt;
          &lt;speed&gt;0.0&lt;/speed&gt;
          &lt;src&gt;gps&lt;/src&gt;
          &lt;sat&gt;6&lt;/sat&gt;
          &lt;time&gt;2011-08-26T06:25:20Z&lt;/time&gt;
        &lt;/trkpt&gt;
        &lt;trkpt  lat="46.94758878281887"  lon="7.398622951942811" &gt;
          &lt;ele&gt;748.0&lt;/ele&gt;
          &lt;speed&gt;0.0&lt;/speed&gt;
          &lt;src&gt;gps&lt;/src&gt;
          &lt;sat&gt;5&lt;/sat&gt;
          &lt;time&gt;2011-08-26T06:30:56Z&lt;/time&gt;
        &lt;/trkpt&gt;
  
  ...   ...   ...
  
      &lt;/trkseg&gt;
    &lt;/trk&gt;
  &lt;/gpx&gt;
  </code></pre>
  
  <p>Is it possible to traverse a directory containing these files and load them into one PostGIS table using either SQL or Python?</p>
  
  <p>I've stubled upon <a href="http://postneo.com/2007/01/20/from-gpx-to-postgis" rel="nofollow">this</a> blog post mentioning that: </p>
  
  <blockquote>
    <p>I’m not aware of anything that can convert straight from GPX to
    PostGIS</p>
  </blockquote>
  
  <p><a href="http://www.postgresonline.com/journal/archives/116-Loading-and-Processing-GPX-XML-files-using-PostgreSQL.html" rel="nofollow">This post</a> gives an example of working with SQL to do that but I can't get my head around the code :/</p>