以未记录的时间戳插入坐标 [英] Interpolate coordinates at unrecorded timestamps

查看:99
本文介绍了以未记录的时间戳插入坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gps单位,它以相当随机的间隔(有时每12秒,有时每6秒)记录一次坐标.还有另一种仪器可以每秒测量一次颗粒物.我正在寻找一种方法,可根据现有坐标和运动速度以每秒未记录的时间戳对坐标进行插值,以便将gps数据与颗粒物数据集合并.为了使事情变得容易一些,我可以假设两个连续坐标之间的路线是直线,并且以恒定速度行进.因此,我需要做的就是在两个坐标之间每隔一秒钟分配一次,两个连续坐标之间的差除以秒之间的时间差.以下面的数据集为例,我可以将09:32:01处的X和Y分配给325695 +(325695-325695)/12和672878 +(672857-672878)/12. R中是否有任何允许类似计算的函数.既然这在GIS领域似乎是很普遍的操作,那么也许在ArcGIS中为此设计了一个特定的工具?

I have a gps units that records coordinates at rather random intervals (sometimes every 12 sec sometimes every 6 sec). There's another instrument that measures particulate matter at every second. I'm looking for a way to interpolate the coordinates at unrecorded timestamps for every second based on the existing coordinates and the speed of the movement, so that I can merge the gps data with the particulate matter dataset. To make things a bit easier, I can assume that the route between two consecutive coordinates is straight line and is travelled at a constant speed. So all I need to do is to assign every second in-between two coordinates with the difference between two consecutive coordinates recorded divided by the difference in time in second. Taking the dataset below for example, I can assign X and Y at 09:32:01 to 325695 + (325695-325695)/12 and 672878 + (672857-672878)/12. So is there any function in R that allows similar calculation. Since it seems to be a quite common operation in the GIS area, maybe there's a specific tool designed for this in ArcGIS?

date          time         X       Y    
04/06/2014  09:32:00    325695  672878  
04/06/2014  09:32:12    325695  672857  
04/06/2014  09:32:24    325694  672845  
04/06/2014  09:32:36    325690  672825  
04/06/2014  09:32:48    325685  672803  
04/06/2014  09:33:00    325685  672783  

欢迎任何建议和想法.

谢谢

推荐答案

由于数据是时间序列,因此最好在软件包zoo中使用na.approx(...).

Since your data is a time series, you're better off using na.approx(...) in package zoo.

df$date.time <- with(df,as.POSIXct(paste(date,time),format="%m/%d/%Y %H:%M:%S"))
full.time    <- with(df,seq(date.time[1],tail(date.time,1),by=1))
library(zoo)
df.zoo <- zoo(df[,3:4],df$date.time)        # convert to zoo object
result <- na.approx(df.zoo,xout=full.time)  # interpolate; result is also a zoo object
head(result)
                         X        Y
2014-04-06 09:32:00 325695 672878.0
2014-04-06 09:32:01 325695 672876.2
2014-04-06 09:32:02 325695 672874.5
2014-04-06 09:32:03 325695 672872.8
2014-04-06 09:32:04 325695 672871.0
2014-04-06 09:32:05 325695 672869.2

如果需要在网格点处连续导数,则还有一个na.spline(...)函数.

There is also an na.spline(...) function if you need continuous derivatives at the grid points.

这篇关于以未记录的时间戳插入坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆