Skip to content

'speed' values are NA , but not really #260

Description

@rafapereirabr

I'm finding a strange behavior in gtfs2gps(). In the reprex below, I filter a single trip and convert it to a GPS-like table. The problem is that the gtfs2gps() function prints a message saying 'speed' values are NA for shape_id '60-1-b12-1.1.O'. This message seems to suggest all speed values in this trip are NA, but they are not. This seems to be a problem in the code. The message should not be printed in this case, right?

The function is able to calculate the speed correctly, as seen in the outupt. There is only one NA in the last segment (as expected). So the function also prints the message Some 'speed' values are NA in the returned data.. As a rule, there will always be one NA in the last trip segment, right? So perhaps this message is unecessary. What do you guys think?

reprex

library(gtfs2gps)
library(ggplot2)
library(gtfstools)
library(data.table)

# path to GTFS.zip file
gtfs_file <- system.file("extdata/irl_dub/irl_dub_gtfs.zip", package = "gtfs2emis")

# read GTFS
gtfs <- gtfstools::read_gtfs(gtfs_file)

# Keep Monday services GTFS
gtfs <- gtfstools::filter_by_weekday(gtfs, 
                                     weekday = c('saturday', 'sunday'), 
                                     keep = FALSE)
# filter trip
id <- '6343.2.60-1-b12-1.1.O'
gtfs <- gtfstools::filter_by_trip_id(gtfs, trip_id =  id )


head(gtfs$trips)
head(gtfs$stop_times)
head(gtfs$stops)
head(gtfs$shapes)

# convert to gps
gps <- gtfs2gps(gtfs)
gps_sf <- gtfs2gps::gps_as_sflinestring(gps)

# plot
stops_df <- gtfstools::convert_stops_to_sf(gtfs)

ggplot() +
  geom_sf(data=gps_sf, aes(color=as.numeric(speed))) +
  geom_sf(data=stops_df, color='red') 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions