如果有人能看一看,我们将不胜感激。非常感谢。
R中的移动包有问题——在下一步设置动画之前,试图将其转换为移动类
df<- structure(list(location.long = c(103.788045, 103.788979, 103.788979,
103.788979, 103.789537, 103.788979, 103.789075, 103.789075, 103.784314,
103.784314, 103.784814, 103.784814, 103.785765, 103.78625, 103.78456,
103.78411, 103.78411, 103.78482, 103.78482, 103.78484), location.lat = c(1.403669966,
1.400432959, 1.400432959, 1.400432959, 1.400409993, 1.400432959,
1.399945971, 1.399945971, 1.40191203, 1.40191203, 1.402777964,
1.402777964, 1.403566031, 1.403750014, 1.4021, 1.40206, 1.40206,
1.40229, 1.40229, 1.40231), timestamp = structure(1:20, .Label = c("12/3/20 10:09",
"12/3/20 16:05", "12/3/20 16:35", "12/3/20 17:05", "12/3/20 17:35",
"12/3/20 18:05", "12/3/20 18:35", "12/3/20 19:05", "12/3/20 7:09",
"12/3/20 7:39", "12/3/20 8:12", "12/3/20 8:40", "12/3/20 9:09",
"12/3/20 9:39", "12/6/19 16:40", "12/6/19 17:10", "12/6/19 17:40",
"12/6/19 18:10", "12/6/19 18:40", "12/6/19 19:10", "14/11/19 10:05",
"14/11/19 16:05", "14/11/19 16:35", "14/11/19 16:45", "14/11/19 16:56",
"14/11/19 17:05", "14/11/19 17:35", "14/11/19 18:05", "14/11/19 18:35",
"14/11/19 19:00", "14/11/19 19:05", "14/11/19 7:05", "14/11/19 7:35",
"14/11/19 7:54", "14/11/19 8:05", "14/11/19 8:14", "14/11/19 8:24",
"14/11/19 8:35", "14/11/19 9:05", "14/11/19 9:35", "14/2/20 16:10",
"14/2/20 17:53", "14/2/20 18:10", "14/2/20 18:46", "14/2/20 19:15",
"14/2/20 7:20", "14/2/20 7:55", "14/2/20 8:22", "14/2/20 8:52",
"14/2/20 9:28", "14/2/20 9:56", "15/10/19 10:08", "15/10/19 16:25",
"15/10/19 16:55", "15/10/19 16:59", "15/10/19 17:25", "15/10/19 17:55",
"15/10/19 18:25", "15/10/19 18:55", "15/10/19 19:01", "15/10/19 7:00",
"15/10/19 7:09", "15/10/19 7:30", "15/10/19 7:39", "15/10/19 8:00",
"15/10/19 8:09", "15/10/19 8:30", "15/10/19 8:39", "15/10/19 9:09",
"15/10/19 9:39", "15/5/19 10:10", "15/5/19 10:25", "15/5/19 10:40",
"15/5/19 11:10", "15/5/19 11:40", "15/5/19 12:20", "15/5/19 12:30",
"15/5/19 12:40", "15/5/19 13:00", "15/5/19 13:10", "15/5/19 13:15",
"15/5/19 13:23", "15/5/19 13:40", "15/5/19 14:06", "15/5/19 14:10",
"15/5/19 14:40", "15/5/19 15:05", "15/5/19 15:10", "15/5/19 15:30",
"15/5/19 15:40", "15/5/19 16:00", "15/5/19 16:10", "15/5/19 16:30",
"15/5/19 17:40", "15/5/19 17:50", "15/5/19 17:58", "15/5/19 18:05",
"15/5/19 18:10", "15/5/19 18:40", "15/5/19 18:43", "15/5/19 19:00",
"15/5/19 7:45", "15/5/19 8:13", "15/5/19 8:38", "15/5/19 9:10",
"15/5/19 9:32", "15/5/19 9:44", "16/12/19 10:00", "16/12/19 16:20",
"16/12/19 16:50", "16/12/19 17:20", "16/12/19 17:50", "16/12/19 18:20",
"16/12/19 18:50", "16/12/19 7:00", "16/12/19 7:30", "16/12/19 8:00",
"16/12/19 8:30", "16/12/19 9:00", "16/12/19 9:30", "16/12/19 9:43",
"16/5/19 10:00", "16/5/19 10:23", "16/5/19 10:36", "16/5/19 12:30",
"16/5/19 13:00", "16/5/19 13:30", "16/5/19 16:30", "16/5/19 17:00",
"16/5/19 17:30", "16/5/19 19:00", "16/5/19 19:30", "16/5/19 7:00",
"16/5/19 7:15", "16/5/19 7:18", "16/5/19 7:30", "16/5/19 8:00",
"16/5/19 8:30", "16/5/19 8:48", "16/5/19 9:00", "16/5/19 9:13",
"16/5/19 9:30", "17/5/19 10:10", "17/5/19 10:40", "17/5/19 10:54",
"17/5/19 11:10", "17/5/19 11:32", "17/5/19 11:40", "17/5/19 12:10",
"17/5/19 13:10", "17/5/19 14:10", "17/5/19 14:24", "17/5/19 14:40",
"17/5/19 15:00", "17/5/19 15:10", "17/5/19 15:18", "17/5/19 15:40",
"17/5/19 16:10", "17/5/19 16:40", "17/5/19 17:10", "17/5/19 17:40",
"17/5/19 18:00", "17/5/19 7:10", "17/5/19 7:40", "17/5/19 7:56",
"17/5/19 8:07", "17/5/19 8:40", "17/5/19 9:10", "17/5/19 9:40",
"17/9/19 10:00", "17/9/19 16:05", "17/9/19 16:35", "17/9/19 16:45",
"17/9/19 17:05", "17/9/19 17:35", "17/9/19 18:05", "17/9/19 18:35",
"17/9/19 19:05", "17/9/19 7:00", "17/9/19 7:10", "17/9/19 7:25",
"17/9/19 7:30", "17/9/19 7:40", "17/9/19 7:55", "17/9/19 8:00",
"17/9/19 8:20", "17/9/19 8:22", "17/9/19 8:25", "17/9/19 8:30",
"17/9/19 8:35", "17/9/19 8:47", "17/9/19 8:55", "17/9/19 9:00",
"17/9/19 9:25", "17/9/19 9:30", "17/9/19 9:55", "18/6/19 16:10",
"18/6/19 16:40", "18/6/19 17:10", "18/6/19 17:40", "18/6/19 18:10",
"18/6/19 18:40", "18/6/19 19:10", "20/11/19 10:00", "20/11/19 7:00",
"20/11/19 7:30", "20/11/19 8:00", "20/11/19 8:10", "20/11/19 8:30",
"20/11/19 9:00", "20/11/19 9:30", "21/11/19 16:05", "21/11/19 16:17",
"21/11/19 16:35", "21/11/19 17:05", "21/11/19 17:35", "21/11/19 18:05",
"21/11/19 18:35", "21/11/19 19:05", "21/5/19 10:08", "21/5/19 7:08",
"21/5/19 7:38", "21/5/19 8:08", "21/5/19 8:48", "21/5/19 9:11",
"21/5/19 9:51", "22/7/19 18:05", "22/7/19 18:35", "22/7/19 18:57",
"22/7/19 19:11", "22/7/19 7:18", "22/7/19 7:50", "22/7/19 7:52",
"24/2/20 16:35", "24/2/20 16:36", "24/2/20 16:48", "24/2/20 16:54",
"24/2/20 17:05", "24/2/20 17:10", "24/2/20 17:35", "24/2/20 18:05",
"24/2/20 18:30", "24/2/20 18:35", "24/2/20 19:05", "24/2/20 7:25",
"24/2/20 7:52", "24/2/20 8:16", "24/2/20 8:45", "24/2/20 9:15",
"24/2/20 9:45", "24/3/20 10:00", "24/3/20 16:00", "24/3/20 16:30",
"24/3/20 17:00", "24/3/20 17:30", "24/3/20 18:00", "24/3/20 18:30",
"24/3/20 19:00", "24/3/20 7:00", "24/3/20 7:30", "24/3/20 8:00",
"24/3/20 8:30", "24/3/20 9:00", "24/3/20 9:30", "24/5/19 16:30",
"24/5/19 16:56", "24/5/19 17:02", "24/5/19 17:16", "24/5/19 17:30",
"24/5/19 17:49", "24/5/19 18:00", "24/5/19 18:30", "24/5/19 18:38",
"24/5/19 18:49", "24/5/19 19:00", "24/5/19 19:30", "25/5/19 10:00",
"25/5/19 16:00", "25/5/19 16:30", "25/5/19 17:00", "25/5/19 17:30",
"25/5/19 17:40", "25/5/19 18:00", "25/5/19 18:18", "25/5/19 18:24",
"25/5/19 18:27", "25/5/19 19:00", "25/5/19 19:30", "25/5/19 7:48",
"25/5/19 8:18", "25/5/19 8:48", "25/5/19 9:18", "25/5/19 9:48",
"25/6/19 10:05", "25/6/19 16:40", "25/6/19 17:10", "25/6/19 17:40",
"25/6/19 18:10", "25/6/19 18:40", "25/6/19 19:10", "25/6/19 7:05",
"25/6/19 7:35", "25/6/19 8:05", "25/6/19 8:20", "25/6/19 8:35",
"25/6/19 9:05", "25/6/19 9:35", "27/5/19 16:30", "27/5/19 17:00",
"27/5/19 17:03", "27/5/19 17:30", "27/5/19 18:00", "27/5/19 18:30",
"27/5/19 19:00", "27/5/19 19:20", "28/5/19 10:00", "28/5/19 10:30",
"28/5/19 10:45", "28/5/19 11:00", "28/5/19 11:30", "28/5/19 12:00",
"28/5/19 12:13", "28/5/19 12:30", "28/5/19 13:00", "28/5/19 13:30",
"28/5/19 14:00", "28/5/19 14:30", "28/5/19 14:50", "28/5/19 16:15",
"28/5/19 16:45", "28/5/19 17:15", "28/5/19 17:49", "28/5/19 18:15",
"28/5/19 18:33", "28/5/19 18:45", "28/5/19 19:10", "28/5/19 7:00",
"28/5/19 7:15", "28/5/19 7:30", "28/5/19 8:00", "28/5/19 8:30",
"28/5/19 9:00", "28/5/19 9:12", "28/5/19 9:30", "28/8/19 16:45",
"28/8/19 17:15", "28/8/19 17:45", "28/8/19 18:15", "28/8/19 18:45",
"28/8/19 6:55", "28/8/19 7:25", "28/8/19 7:55", "28/8/19 8:25",
"28/8/19 8:55", "28/8/19 9:25", "28/8/19 9:55", "29/11/19 10:05",
"29/11/19 7:05", "29/11/19 7:35", "29/11/19 7:50", "29/11/19 8:05",
"29/11/19 8:35", "29/11/19 9:05", "29/11/19 9:35", "29/5/19 10:20",
"29/5/19 10:50", "29/5/19 11:20", "29/5/19 11:37", "29/5/19 11:50",
"29/5/19 12:07", "29/5/19 12:20", "29/5/19 12:50", "29/5/19 13:20",
"29/5/19 13:50", "29/5/19 14:20", "29/5/19 14:50", "29/5/19 15:20",
"29/5/19 15:50", "29/5/19 16:20", "29/5/19 16:50", "29/5/19 17:20",
"29/5/19 17:29", "29/5/19 17:39", "29/5/19 17:50", "29/5/19 18:20",
"29/5/19 18:50", "29/5/19 19:20", "29/5/19 7:20", "29/5/19 7:47",
"29/5/19 7:50", "29/5/19 8:20", "29/5/19 8:43", "29/5/19 8:50",
"29/5/19 9:20", "29/5/19 9:50", "3/10/19 10:10", "3/10/19 15:55",
"3/10/19 16:25", "3/10/19 16:55", "3/10/19 17:25", "3/10/19 17:42",
"3/10/19 17:55", "3/10/19 18:25", "3/10/19 18:50", "3/10/19 7:00",
"3/10/19 7:11", "3/10/19 7:28", "3/10/19 7:40", "3/10/19 8:05",
"3/10/19 8:10", "3/10/19 8:40", "3/10/19 9:10", "3/10/19 9:40",
"31/1/20 16:20", "31/1/20 16:50", "31/1/20 17:20", "31/1/20 17:40",
"31/1/20 17:50", "31/1/20 18:20", "31/1/20 7:10", "31/1/20 7:40",
"31/1/20 8:10", "31/1/20 8:40", "6/12/19 17:07", "6/12/19 17:35",
"6/12/19 18:15", "6/12/19 18:47", "7/1/20 10:00", "7/1/20 16:15",
"7/1/20 16:45", "7/1/20 17:15", "7/1/20 17:45", "7/1/20 18:15",
"7/1/20 18:29", "7/1/20 18:45", "7/1/20 7:30", "7/1/20 8:00",
"7/1/20 8:30", "7/1/20 9:00", "7/1/20 9:30", "7/6/19 10:10",
"7/6/19 16:10", "7/6/19 16:40", "7/6/19 17:10", "7/6/19 17:40",
"7/6/19 18:10", "7/6/19 18:40", "7/6/19 19:10", "7/6/19 7:50",
"7/6/19 8:20", "7/6/19 8:42", "7/6/19 8:50", "7/6/19 9:20", "7/6/19 9:45",
"8/7/19 16:05", "8/7/19 17:35", "8/7/19 18:05", "8/7/19 18:35",
"8/7/19 19:05", "8/7/19 6:55", "8/7/19 7:25", "8/7/19 7:55",
"8/7/19 8:10", "8/7/19 8:25", "8/7/19 8:55", "8/7/19 9:25", "8/7/19 9:30",
"8/7/19 9:55", "8/8/19 10:10", "8/8/19 15:55", "8/8/19 16:25",
"8/8/19 16:31", "8/8/19 16:55", "8/8/19 17:25", "8/8/19 17:32",
"8/8/19 17:55", "8/8/19 18:25", "8/8/19 18:55", "8/8/19 19:20",
"8/8/19 7:10", "8/8/19 7:40", "8/8/19 8:10", "8/8/19 8:40", "8/8/19 9:10",
"8/8/19 9:40", "9/9/19 10:05", "9/9/19 10:20", "9/9/19 16:50",
"9/9/19 17:20", "9/9/19 17:50", "9/9/19 18:05", "9/9/19 18:20",
"9/9/19 18:35", "9/9/19 18:50", "9/9/19 19:15", "9/9/19 7:05",
"9/9/19 7:35", "9/9/19 7:52", "9/9/19 7:55", "9/9/19 8:05", "9/9/19 8:20",
"9/9/19 8:35", "9/9/19 9:05", "9/9/19 9:35", "9/9/19 9:55"), class = "factor"),
troop = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Main",
"Sub-Group"), class = "factor"), survey_method = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), .Label = c("Ad_libitum", "Scan"), class = "factor"),
data_tag = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("NSF-B1",
"NSF-B2", "NSF-F1", "NSF-F2", "NSF-F3", "NSF-M10a", "NSF-M10b",
"NSF-M1a", "NSF-M1a/R1", "NSF-M1b", "NSF-M1b/R4", "NSF-M2a",
"NSF-M2b", "NSF-M3a", "NSF-M3b", "NSF-M4a", "NSF-M4b", "NSF-M5a",
"NSF-M5b", "NSF-M6a", "NSF-M6b", "NSF-M7a", "NSF-M7b", "NSF-M8a",
"NSF-M8b", "NSF-M9a", "NSF-M9b", "NSF-P1", "NSF-P2", "NSF-P3",
"NSF-R2", "NSF-R3"), class = "factor")), row.names = c(581L,
582L, 583L, 584L, 585L, 586L, 587L, 588L, 575L, 576L, 577L, 578L,
579L, 580L, 377L, 378L, 379L, 380L, 381L, 382L), class = "data.frame")
#reorder timestamps in ascending order
df<-df[order(df$timestamp),]
#remove duplicates
df <- df[!duplicated(df$timestamp),]
m <- df2move(df, x = df$"location.long", y=df$"location.lat",
time=as.POSIXct(df$"timestamp",format="%Y-%m-%d %H:%M:%S", tz="Singapore"),
proj ="+proj=longlat +datum=WGS84 +no_defs",
removeDuplicatedTimestamps=T)
#>Error: Column named '103.78751' cannot be found in 'df'.
我不知道为什么在这个错误代码中提到df,而103.78751是一行而不是列。如有任何帮助,我们将不胜感激。
如果读取?df2move
,则需要x
、y
和time
列作为列的名称,而不是值。此外,time
列需要属于POSIXct
类。所以试试:
df$timestamp <- as.POSIXct(df$timestamp, format = '%d/%m/%y %H:%M', tz='Singapore')
m <- moveVis::df2move(df, x = 'location.long', y= 'location.lat',
time= 'timestamp',
proj ="+proj=longlat +datum=WGS84 +no_defs",
removeDuplicatedTimestamps=T)
m
#class : Move
#features : 20
#extent : 103.7841, 103.7895, 1.399946, 1.40375 (xmin, xmax, ymin, ymax)
#crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
#variables : 3
#names : x, y, time
#min values : 103.78411, 1.399945971, 1560328800
#max values : 103.789537, 1.403750014, 1584011100
#timestamps : 2019-06-12 16:40:00 ... 2020-03-12 19:05:00 Time difference #of 274 days (start ... end, duration)
#sensors : unknown
#indiv. data :
#indiv. value:
#date created: 2020-04-26 15:27:31