Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I've connected a USB GPS device and am able to write them to a file using gpspipe.

There are limitations though:

  • does not record in KML
  • existing tools for conversion to KML don't seem to interpret timestamps

How can I record GPS data to KML format, either on the fly or preferably when I stop writing?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

gpspipe -r should produce clean NMEA data, but the version provided with Raspbian adds some JSON noise at the start that really doesn't belong. To output just NMEA sentences from gpspipe, this is what worked for me:

gpspipe -r | grep '^\$G' | tee test3.nmea

This filters out just the NMEA data, and copies the output to the screen and to the file test3.nmea.

You can convert this to KML using gpsbabel:

gpsbabel -i nmea -f test3.nmea -o kml -F test3.kml

Each of the points includes a timestamp, f'rinstance:

      <Placemark>
        <name>-3</name>
        <snippet/>
        <description><![CDATA[
          <table>
            <tr><td>Longitude: -79.264922 </td></tr>
            <tr><td>Latitude: 43.730687 </td></tr>
            <tr><td>Altitude: 502.953 ft </td></tr>
            <tr><td>Speed: 1.4 mph </td></tr>
            <tr><td>Heading: 221.5 </td></tr>
            <tr><td>Time: 2012-12-15T21:27:34Z </td></tr>
          </table>
        ]]></description>
        <LookAt>
          <longitude>-79.264922</longitude>
          <latitude>43.730687</latitude>
          <tilt>66</tilt>
        </LookAt>
        <TimeStamp><when>2012-12-15T21:27:34Z</when></TimeStamp>
        <styleUrl>#track</styleUrl>
        <Point>
          <coordinates>-79.264922,43.730687,153.30</coordinates>
        </Point>
      </Placemark>

If you want something that Google Earth can still read, but has cleaner metadata, I'd recommend GPX. You can make it with:

gpsbabel -i nmea -f test3.nmea -o gpx -F test3.gpx

Each trackpoint will look a bit like:

<trkpt lat="43.730533333" lon="-79.265021667">
  <ele>169.000000</ele>
  <time>2012-12-15T21:28:10Z</time>
  <course>186.539993</course>
  <speed>1.347844</speed>
  <fix>3d</fix>
  <sat>4</sat>
  <hdop>4.300000</hdop>
  <vdop>1.000000</vdop>
  <pdop>4.400000</pdop>
</trkpt>

These results were tested and generated on a Raspberry Pi running latest Raspbian, with gpsd reading from a Pharos GPS-500 on /dev/ttyUSB0.

Does your GPS have a satellite fix? Check with cgps/xgps, and see that the Status is at least '2D Fix'. If you're indoors and haven't warm-started your GPS receiver, you may never get a fix. You'll still get NMEA data, just it doesn't contain $GPRMC position data.

share|improve this answer
add comment

Gpsbabel should be the best solution for you. Here I found documentation for you about kml in gpsbabel. For more information the best way will be check man pages after install it on your pi.

You should be able to convert files easly. Here is example for other format:

gpsbabel -t -i kml -f one.kml -x track,title=$name -o gpx -F one.gpx
gpsbabel -t -i gpx -f one.gpx -o garmin -F usb:0

Docs: http://www.gpsbabel.org/htmldoc-1.4.2/fmt_kml.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.