Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"argument is of length zero" for trkpt with no lat/lon #22

Open
hugovk opened this issue Sep 23, 2019 · 1 comment
Open

"argument is of length zero" for trkpt with no lat/lon #22

hugovk opened this issue Sep 23, 2019 · 1 comment

Comments

@hugovk
Copy link
Contributor

hugovk commented Sep 23, 2019

I have a GPX from my Strava ZIP that looks like this (I've snipped away most of the track points), where the first <trkpt> has no lon or lat attributes:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" creator="Wahoo ELEMNT BOLT" version="5.8">
  <metadata>
    <link href="https://gotoes.org/strava/Combine_GPX_TCX_FIT_Files.php">
      <text>GOTOES STRAVA TOOLS</text>
    </link>
    <time>2019-08-31T09:02:36Z</time>
  </metadata>
  <trk>
    <type>Other</type>
    <trkseg>
      <trkpt>
        <ele>31.2</ele>
        <time>2019-08-31T09:02:36Z</time>
        <extensions>
          <gpxdata:temp>0</gpxdata:temp>
        </extensions>
      </trkpt>
      <trkpt lon="24.93841" lat="60.16992">
        <ele>31.2</ele>
        <time>2019-08-31T09:02:37Z</time>
        <extensions>
          <gpxdata:temp>29</gpxdata:temp>
        </extensions>
      </trkpt>
      <trkpt lon="24.93841" lat="60.16992">
        <ele>31.2</ele>
        <time>2019-08-31T09:02:38Z</time>
        <extensions>
          <gpxdata:temp>29</gpxdata:temp>
        </extensions>
      </trkpt>
    </trkseg>
  </trk>
</gpx>

Putting that at /tmp/test/test.gpx and running:

> library(gtools)
> library(strava)
> library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
✔ ggplot2 3.2.0purrr   0.3.2tibble  2.1.3dplyr   0.8.1tidyr   0.8.3stringr 1.4.0readr   1.3.1forcats 0.4.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
> data <- process_data("/tmp/test")
Error in if (ncol(coords) < 2) return(NULL) : argument is of length zero

It probably happens because the first track point doesn't have latitude or longitude attributes (see GPX above).

Can such track points be skipped?

About the data: the problematic file was generated by combining two files using this tool, which is recommended by Strava so will be quite widely used. I don't have the original pre-merge files handy to check if the same issue occurs there or if it was introduced by the merge tool.

@narfel
Copy link

narfel commented Jan 28, 2020

Just my two cents: Since you will invariably have to prepare gpx files these days anyway, i'm afraid the solution of cleaning up bogus trackpoints is outside the scope of this script. A trackpoint with no coordinates is pointless (sorry about that 💃 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants