最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - Subsampling time series GPS data - Stack Overflow

programmeradmin3浏览0评论

I've been working with GPS data for some time now. I've been reading my scripts and realized I made a mistake during subsampling. Indeed, I wanted to subsample my GPS data with at most 1 GPS position every 15 minutes, for each individual tracked. To do so you can see here my initial method:


data_sub <- data%>%
  mutate(
    year = year(Date_Time), month = month(Date_Time), day = day(Date_Time), 
    hour = as.factor(hour(Date_Time)), minute = minute(Date_Time), 
    .after = Time)%>%
  
  group_by(Individual_ID,year, month, day, hour, minute) %>%
 
 slice_sample(n = 1) %>%
 ungroup()%>%  
 group_by(Individual_ID)%>%
 arrange(Date_Time)%>%
 
 mutate(Duration_m = as.numeric(Date_Time - lag(Date_Time), units = 'mins'), .after = Time) %>% 
  filter(Duration_m >= 15) %>%
  dplyr::select(-c(year,month,day,minute))%>%
  ungroup()

However, after thinking about it, I realised that for example : during an hour positions were taken every second (high-frequency data for example), then all this positions will be removed since the time difference between each is less 15 minutes. However what I wanted to do was to select one position every 15 minutes (it can be more since sometimes gaps of several hours can exists). In this example, I could have taken at most 4 four positions. The method method is quite clear in my head but I can't manage to translate it into R.

发布评论

评论列表(0)

  1. 暂无评论