trackerproject / trackeR

Infrastructure for Running, Cycling and Swimming Data from GPS-Enabled Tracking Devices
http://cran.r-project.org/package=trackeR
90 stars 7 forks source link

Missing time #1

Closed lgatto closed 8 years ago

lgatto commented 8 years ago

I am trying to read a TCX file (exported from MapMyRun, I believe), but am missing the time and probably speed fields.

> head(runDF <- readTCX("~/Documents/Runs/Ran 10.11 km on 28-04-2016.tcx"))
  time latitude longitude altitude distance heart.rate speed cadence power
1 <NA> 52.22708 0.1185190       60  0.00000         NA    NA      NA    NA
2 <NA> 52.22716 0.1186463       60 12.24020         NA    NA      NA    NA
3 <NA> 52.22724 0.1187061       61 22.51196         NA    NA      NA    NA
4 <NA> 52.22734 0.1187619       63 33.56483         NA    NA      NA    NA
5 <NA> 52.22744 0.1188195       63 45.60642         NA    NA      NA    NA
6 <NA> 52.22754 0.1188363       64 57.22373         NA    NA      NA    NA

Looking at the file itself, and parsing the time manually, I don't understand why it doesn't work. Here's the first track point:

<Trackpoint>
   <Time>
     2016-04-28T14:32:24.734000+00:00
   </Time>
   <Position>
     <LatitudeDegrees>
     52.2270829
     </LatitudeDegrees>
     <LongitudeDegrees>
     0.11851899
     </LongitudeDegrees>
   </Position>
   <AltitudeMeters>
     60.0
   </AltitudeMeters>
   <DistanceMeters>
     0.0
   </DistanceMeters>
</Trackpoint>

and the time parse manually with as.POSIXct (as documented in ?readTCX)

> as.POSIXct("2016-04-28T14:32:24.734000+00:00")
[1] "2016-04-28 BST"

Any idea?

hfrick commented 8 years ago

The format for as.POSIXct used in readTCX isn't as flexible as the specification of datetime in the TCX format - thanks for pointing that out!