forked from piLaboratory/jaguar-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JaguarMapMove.r
5248 lines (4908 loc) · 277 KB
/
JaguarMapMove.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###########################################################################################################
############# Jaguar Map Move ##############
###########################################################################################################
######################################## Preparation ######################################################
rm(list= ls()) ### For a fresh start
## Commented because is not generic
#setwd("C:/RWorkDir/jaguardatapaper") ### Set directory
###########################################################################################################
###Enter jaguar data from Morato et al. 2018/ Bernardo scripts
## Load packages
if(!require(install.load)) install.packages('install.load'); library(install.load)
install.load::install_load("ggmap","maptools",'move',"circular","RCurl","dplyr","readr","caTools","adehabitatLT","ggsn","magick","rgl","tidyverse","htmltools","rglwidget")
### The require() can be used inside functions as it gives a warning message and returns a logical value.
### FALSE if the requested package is not found and TRUE if the package is loaded.###(Movement data should be checked and cleaned (for outliers, duplicated timestamps, etc)first!!!
### Load and adjust the data (already cleaned) and create a dataframe object
#mov.data.org <- read.delim(file="c:/RWorkDir/jaguardatapaper/mov.data.org.txt") ## comentted because it is a local path
mov.data.org <- dplyr::select(mov.data.org, -(individual.taxon.canonical.name:tag.local.identifier))
str(mov.data.org)
# Add Individual info ## Commented because is not generic!!!
#info <- read.delim(file="c:/RWorkDir/jaguardatapaper/info.txt") ### preparation to merge deleted
#Merge movement with individual info/parameters
merged<- merge(mov.data.org,info)
mov.data.org <- merged
str(mov.data.org)
##########################
# Organize data
#mov.data.org
# Add 2000 to years
get.year <- function(time.stamp) {
init <- gregexpr('/', time.stamp, fixed = T)[[1]][2] + 1
end <- gregexpr(' ', time.stamp, fixed = T)[[1]][1] - 1
substr(time.stamp, init, end)
}
# Test
get.year(time.stamp = mov.data.org$timestamp[10000])
# All individuals
year <- as.numeric(sapply(mov.data.org$timestamp, get.year))
table(year)
# Add 1900/2000
new.year <- as.character(ifelse(year > 50, year + 1900, year + 2000))
table(new.year)
# New dates
set.year <- function(time.stamp, year) {
init <- gregexpr('/', time.stamp, fixed = T)[[1]][2]
end <- gregexpr(' ', time.stamp, fixed = T)[[1]][1]
paste(substr(time.stamp, 1, init), year,
substr(time.stamp, end, nchar(time.stamp)), sep = "")
}
# Test
set.year(time.stamp = as.character(mov.data.org$timestamp[10000]), year = '2013')
# All individuals
date.time <- as.character(mapply(set.year, as.character(mov.data.org$timestamp),
new.year))
str(date.time)
#date.time
#########################################################
# All individuals
date.time <- as.character(mapply(set.year, as.character(mov.data.org$timestamp),
new.year))
str(date.time)
#date.time
# Date/Time as POSIXct object
mov.data.org$timestamp.posix <- as.POSIXct(date.time,
format = "%m/%d/%Y %H:%M", tz = 'GMT')
# We need to adjust this POSIXct object to local time
# Example:
# mov.data.org$timestamp.posix - 3*60*60 # here we need to load the local time for each individual
str(mov.data.org)
#-----------------------------
# Distribution of fix rates
mov.data.diff <- mov.data.org
# Calculation of time between fixes
time.between <- function(individual, dat) {
# Select individual
ind <- dat[dat$individual.local.identifier..ID. == individual,]
# Calculate difference in time, in hours, and return
c(as.numeric(diff.POSIXt(ind$timestamp.posix), units = 'hours'), NA)
}
# All individuals
inds <- unique(mov.data.diff$individual.local.identifier..ID.)
mov.data.diff$time.diff <- unlist(sapply(inds, FUN = time.between, dat = mov.data.diff))
# Histogram
for(i in inds) {
print(paste(i, paste(range(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == i], na.rm = T), collapse = ', '), sep = ': '))
}
hist(mov.data.diff$time.diff[mov.data.diff$time.diff > 0 & mov.data.diff$time.diff < 48],
main = 'All individuals pooled', xlab = "Time between fixes (h)")
#-----------------------------
## adehabitatLT
# Transforms in ltraj object
coords <- data.frame(mov.data.org$location.long, mov.data.org$location.lat)
mov.traj <- as.ltraj(xy = coords, date=mov.data.org$timestamp.posix,
id=mov.data.org$individual.local.identifier..ID.,
burst=mov.data.org$individual.local.identifier..ID.,
infolocs = mov.data.org[,-c(3:4, ncol(mov.data.org))])
mov.traj.df <- ld(mov.traj)
#mov.traj
#plot(mov.traj)
#hist(mov.traj.df$dist)
## move
# Organize data as a move package format
move.data <- move(x = mov.traj.df$x, y = mov.traj.df$y,
time = mov.traj.df$date,
proj = CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'),
data = mov.traj.df, animal = mov.traj.df$id, sensor = 'GPS')
move.data ### moveStack
###Separate individual animals' trajectories
unstacked <- split(move.data)
head(unstacked)
jaguar_df <- as(move.data, "data.frame")
## Plot individual animals' trajectories (Maximum Zoom to include all points)
#X1
unstacked <- split(move.data)
X1=unstacked$X1
X1_df <- as(X1, "data.frame")
head(X1_df)
nrow(X1_df)
range(X1_df$date)
m <- get_map(bbox(extent(X1)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X1_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#aes(colour = as.numeric(date)
#geom_point
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X1_df, plot3d(x,y,date, type="l", col=as.numeric(X1_df$Event_ID)))
(stcube<-with(X1_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X1_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X1, units="mins"))
head(timeLag(X1, units="hours"))
median(timeLag(X1, units="hours"))
max(timeLag(X1, units="hours"))
max(timeLag(X1, units="days"))
plot(X1_df$individual.local.identifier..ID.~X1_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X1,file="c:/RWorkDir/jaguardatapaper/ID/X1.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 1],
main = 'Individual 1', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 1],
na.rm = T), main = 'Individual 1')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 1 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 1',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X2
X2=unstacked$X2
X2_df <- as(X2, "data.frame")
head(X2_df)
nrow(X2_df)
range(X2_df$date)
m <- get_map(bbox(extent(X2)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X2_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#m <- get_map(bbox(extent(X2)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
#ggmap(m)+geom_path(data=X2_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X2_df, plot3d(x,y,date, type="l", col=as.numeric(X2_df$Event_ID)))
(stcube<-with(X2_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X2_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X2, units="mins"))
head(timeLag(X2, units="hours"))
median(timeLag(X2, units="hours"))
max(timeLag(X2, units="hours"))
max(timeLag(X2, units="days"))
plot(X2_df$individual.local.identifier..ID.~X2_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X2,file="c:/RWorkDir/jaguardatapaper/ID/X2.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 2],
main = 'Individual 2', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 2],
na.rm = T), main = 'Individual 2')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 2 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 2',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X3
X3=unstacked$X3
X3_df <- as(X3, "data.frame")
head(X3_df)
nrow(X3_df)
range(X3_df$date)
m <- get_map(bbox(extent(X3)*1.1), source="google", zoom=10, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X3_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#m <- get_map(bbox(extent(X3)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
#ggmap(m)+geom_path(data=X3_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#Miss 1 row
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X3_df, plot3d(x,y,date, type="l", col=as.numeric(X3_df$Event_ID)))
(stcube<-with(X3_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X3_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X3, units="mins"))
head(timeLag(X3, units="hours"))
median(timeLag(X3, units="hours"))
max(timeLag(X3, units="hours"))
max(timeLag(X3, units="days"))
plot(X3_df$individual.local.identifier..ID.~X3_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X3,file="c:/RWorkDir/jaguardatapaper/ID/X3.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 3],
main = 'Individual 3', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 3],
na.rm = T), main = 'Individual 3')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 3 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 3',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X4
X4=unstacked$X4
X4_df <- as(X4, "data.frame")
head(X4_df)
nrow(X4_df)
range(X4_df$date)
m <- get_map(bbox(extent(X4)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X4_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X4_df, plot3d(x,y,date, type="l", col=as.numeric(X4_df$Event_ID)))
(stcube<-with(X4_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X4_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X4, units="mins"))
head(timeLag(X4, units="hours"))
median(timeLag(X4, units="hours"))
max(timeLag(X4, units="hours"))
max(timeLag(X4, units="days"))
plot(X4_df$individual.local.identifier..ID.~X4_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X4,file="c:/RWorkDir/jaguardatapaper/ID/X4.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 4],
main = 'Individual 4', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 4],
na.rm = T), main = 'Individual 4')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 4 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 4',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X5
X5=unstacked$X5
X5_df <- as(X5, "data.frame")
head(X5_df)
nrow(X5_df)
range(X5_df$date)
m <- get_map(bbox(extent(X5)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X5_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X5)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X5_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X5_df, plot3d(x,y,date, type="l", col=as.numeric(X5_df$Event_ID)))
(stcube<-with(X5_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X5_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X5, units="mins"))
head(timeLag(X5, units="hours"))
median(timeLag(X5, units="hours"))
max(timeLag(X5, units="hours"))
max(timeLag(X5, units="days"))
plot(X5_df$individual.local.identifier..ID.~X5_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X5,file="c:/RWorkDir/jaguardatapaper/ID/X5.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 5],
main = 'Individual 5', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 5],
na.rm = T), main = 'Individual 5')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 5 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 5',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X6
X6=unstacked$X6
X6_df <- as(X6, "data.frame")
head(X6_df)
nrow(X6_df)
range(X6_df$date)
m <- get_map(bbox(extent(X6)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X6_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X6)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X6_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X6_df, plot3d(x,y,date, type="l", col=as.numeric(X6_df$Event_ID)))
(stcube<-with(X6_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X6_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X6, units="mins"))
head(timeLag(X6, units="hours"))
median(timeLag(X6, units="hours"))
max(timeLag(X6, units="hours"))
max(timeLag(X6, units="days"))
plot(X6_df$individual.local.identifier..ID.~X6_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X6,file="c:/RWorkDir/jaguardatapaper/ID/X6.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 6],
main = 'Individual 6', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 6],
na.rm = T), main = 'Individual 6')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 6 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 6',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X7
X7=unstacked$X7
X7_df <- as(X7, "data.frame")
head(X7_df)
nrow(X7_df)
range(X7_df$date)
m <- get_map(bbox(extent(X7)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X7_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X7)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X7_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X7_df, plot3d(x,y,date, type="l", col=as.numeric(X7_df$Event_ID)))
(stcube<-with(X7_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X7_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X7, units="mins"))
head(timeLag(X7, units="hours"))
median(timeLag(X7, units="hours"))
max(timeLag(X7, units="hours"))
max(timeLag(X7, units="days"))
plot(X7_df$individual.local.identifier..ID.~X7_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X7,file="c:/RWorkDir/jaguardatapaper/ID/X7.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 7],
main = 'Individual 7', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 7],
na.rm = T), main = 'Individual 7')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 7 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 7',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X8
X8=unstacked$X8
X8_df <- as(X8, "data.frame")
head(X8_df)
nrow(X8_df)
range(X8_df$date)
m <- get_map(bbox(extent(X8)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X8_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#m <- get_map(bbox(extent(X8)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
#ggmap(m)+geom_path(data=X8_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#6 row warning
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X8_df, plot3d(x,y,date, type="l", col=as.numeric(X8_df$Event_ID)))
(stcube<-with(X8_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X8_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X8, units="mins"))
head(timeLag(X8, units="hours"))
median(timeLag(X8, units="hours"))
max(timeLag(X8, units="hours"))
max(timeLag(X8, units="days"))
plot(X8_df$individual.local.identifier..ID.~X8_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X8,file="c:/RWorkDir/jaguardatapaper/ID/X8.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 8],
main = 'Individual 8', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 8],
na.rm = T), main = 'Individual 8')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 8 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 8',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X9
X9=unstacked$X9
X9_df <- as(X9, "data.frame")
head(X9_df)
nrow(X9_df)
range(X9_df$date)
m <- get_map(bbox(extent(X9)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X9_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X9)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X9_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X9_df, plot3d(x,y,date, type="l", col=as.numeric(X9_df$Event_ID)))
(stcube<-with(X9_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X9_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X9, units="mins"))
head(timeLag(X9, units="hours"))
median(timeLag(X9, units="hours"))
max(timeLag(X9, units="hours"))
max(timeLag(X9, units="days"))
plot(X9_df$individual.local.identifier..ID.~X9_df$date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X9,file="c:/RWorkDir/jaguardatapaper/ID/X9.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 9],
main = 'Individual 9', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 9],
na.rm = T), main = 'Individual 9')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 9 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 9',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X10
unstacked <- split(move.data)
X10=unstacked$X10
X10_df <- as(X10, "data.frame")
head(X10_df)
nrow(X10_df)
range(X10_df$date)
m <- get_map(bbox(extent(X10)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X10_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X10_df, plot3d(x,y,date, type="l", col=as.numeric(X10_df$Event_ID)))
(stcube<-with(X10_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X10_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X10, units="mins"))
head(timeLag(X10, units="hours"))
median(timeLag(X10, units="hours"))
max(timeLag(X10, units="hours"))
max(timeLag(X10, units="days"))
plot(X10_df$individual.local.identifier..ID.~X10_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X10,file="c:/RWorkDir/jaguardatapaper/ID/X10.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 10],
main = 'Individual 10', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 10],
na.rm = T), main = 'Individual 10')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 10 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 10',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X11
unstacked <- split(move.data)
X11=unstacked$X11
X11_df <- as(X11, "data.frame")
head(X11_df)
nrow(X11_df)
range(X11_df$date)
m <- get_map(bbox(extent(X11)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X11_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X11_df, plot3d(x,y,date, type="l", col=as.numeric(X11_df$Event_ID)))
(stcube<-with(X11_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X11_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X11, units="mins"))
head(timeLag(X11, units="hours"))
median(timeLag(X11, units="hours"))
max(timeLag(X11, units="hours"))
max(timeLag(X11, units="days"))
plot(X11_df$individual.local.identifier..ID.~X11_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X11,file="c:/RWorkDir/jaguardatapaper/ID/X11.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 11],
main = 'Individual 11', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 11],
na.rm = T), main = 'Individual 11')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 11 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 11',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X12
unstacked <- split(move.data)
X12=unstacked$X12
X12_df <- as(X12, "data.frame")
head(X12_df)
nrow(X12_df)
range(X12_df$date)
m <- get_map(bbox(extent(X12)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X12_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#m <- get_map(bbox(extent(X12)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
#ggmap(m)+geom_path(data=X12_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X12_df, plot3d(x,y,date, type="l", col=as.numeric(X12_df$Event_ID)))
(stcube<-with(X12_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X12_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X12, units="mins"))
head(timeLag(X12, units="hours"))
median(timeLag(X12, units="hours"))
max(timeLag(X12, units="hours"))
max(timeLag(X12, units="days"))
plot(X12_df$individual.local.identifier..ID.~X12_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X12,file="c:/RWorkDir/jaguardatapaper/ID/X12.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 12],
main = 'Individual 12', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 12],
na.rm = T), main = 'Individual 12')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 12 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 12',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X13
unstacked <- split(move.data)
X13=unstacked$X13
X13_df <- as(X13, "data.frame")
head(X13_df)
nrow(X13_df)
range(X13_df$date)
m <- get_map(bbox(extent(X13)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X13_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#m <- get_map(bbox(extent(X13)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
#ggmap(m)+geom_path(data=X13_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#Removed 15 rows containing missing values (geom_path).
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X13_df, plot3d(x,y,date, type="l", col=as.numeric(X13_df$Event_ID)))
(stcube<-with(X13_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X13_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X13, units="mins"))
head(timeLag(X13, units="hours"))
median(timeLag(X13, units="hours"))
max(timeLag(X13, units="hours"))
max(timeLag(X13, units="days"))
plot(X13_df$individual.local.identifier..ID.~X13_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X13,file="c:/RWorkDir/jaguardatapaper/ID/X13.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 13],
main = 'Individual 13', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 13],
na.rm = T), main = 'Individual 13')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 13 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 13',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X14
unstacked <- split(move.data)
X14=unstacked$X14
X14_df <- as(X14, "data.frame")
head(X14_df)
nrow(X14_df)
range(X14_df$date)
m <- get_map(bbox(extent(X14)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X14_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X14_df, plot3d(x,y,date, type="l", col=as.numeric(X14_df$Event_ID)))
(stcube<-with(X14_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X14_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X14, units="mins"))
head(timeLag(X14, units="hours"))
median(timeLag(X14, units="hours"))
max(timeLag(X14, units="hours"))
max(timeLag(X14, units="days"))
plot(X14_df$individual.local.identifier..ID.~X14_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X14,file="c:/RWorkDir/jaguardatapaper/ID/X14.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 14],
main = 'Individual 14', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 14],
na.rm = T), main = 'Individual 14')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 14 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 14',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X15
unstacked <- split(move.data)
X15=unstacked$X15
X15_df <- as(X15, "data.frame")
head(X15_df)
nrow(X15_df)
range(X15_df$date)
m <- get_map(bbox(extent(X15)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X15_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X15)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X15_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X1_df, plot3d(x,y,date, type="l", col=as.numeric(X1_df$Event_ID)))
(stcube<-with(X15_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X15_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X15, units="mins"))
head(timeLag(X15, units="hours"))
median(timeLag(X15, units="hours"))
max(timeLag(X15, units="hours"))
max(timeLag(X15, units="days"))
plot(X15_df$individual.local.identifier..ID.~X15_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X15,file="c:/RWorkDir/jaguardatapaper/ID/X15.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 15],
main = 'Individual 15', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 15],
na.rm = T), main = 'Individual 15')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 15 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 15',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X16
unstacked <- split(move.data)
X16=unstacked$X16
X16_df <- as(X16, "data.frame")
head(X16_df)
nrow(X16_df)
range(X16_df$date)
m <- get_map(bbox(extent(X16)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X16_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X16)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X16_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X16_df, plot3d(x,y,date, type="l", col=as.numeric(X16_df$Event_ID)))
(stcube<-with(X16_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X16_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X16, units="mins"))
head(timeLag(X16, units="hours"))
median(timeLag(X16, units="hours"))
max(timeLag(X16, units="hours"))
max(timeLag(X16, units="days"))
plot(X16_df$individual.local.identifier..ID.~X16_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X16,file="c:/RWorkDir/jaguardatapaper/ID/X16.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 16],
main = 'Individual 16', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 16],
na.rm = T), main = 'Individual 16')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 16 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 16',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X17
unstacked <- split(move.data)
X17=unstacked$X17
X17_df <- as(X17, "data.frame")
head(X17_df)
nrow(X17_df)
range(X17_df$date)
m <- get_map(bbox(extent(X17)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X17_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X17_df, plot3d(x,y,date, type="l", col=as.numeric(X17_df$Event_ID)))
(stcube<-with(X17_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X17_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X17, units="mins"))
head(timeLag(X17, units="hours"))
median(timeLag(X17, units="hours"))
max(timeLag(X17, units="hours"))
max(timeLag(X17, units="days"))
plot(X17_df$individual.local.identifier..ID.~X17_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X17,file="c:/RWorkDir/jaguardatapaper/ID/X17.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 17],
main = 'Individual 17', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 17],
na.rm = T), main = 'Individual 17')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 17 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 17',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X18
unstacked <- split(move.data)
X18=unstacked$X18
X18_df <- as(X18, "data.frame")
head(X18_df)
nrow(X18_df)
range(X18_df$date)
m <- get_map(bbox(extent(X18)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X18_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X18_df, plot3d(x,y,date, type="l", col=as.numeric(X18_df$Event_ID)))
(stcube<-with(X18_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X18_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X18, units="mins"))
head(timeLag(X18, units="hours"))
median(timeLag(X18, units="hours"))
max(timeLag(X18, units="hours"))
max(timeLag(X18, units="days"))
plot(X18_df$individual.local.identifier..ID.~X18_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X18,file="c:/RWorkDir/jaguardatapaper/ID/X18.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 18],
main = 'Individual 18', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 18],
na.rm = T), main = 'Individual 18')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 18 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 18',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X19
unstacked <- split(move.data)
X19=unstacked$X19
X19_df <- as(X19, "data.frame")
head(X19_df)
nrow(X19_df)
range(X19_df$date)
m <- get_map(bbox(extent(X19)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X19_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X19_df, plot3d(x,y,date, type="l", col=as.numeric(X19_df$Event_ID)))
(stcube<-with(X19_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X19_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X19, units="mins"))
head(timeLag(X19, units="hours"))
median(timeLag(X19, units="hours"))
max(timeLag(X19, units="hours"))
max(timeLag(X19, units="days"))
plot(X19_df$individual.local.identifier..ID.~X19_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X19,file="c:/RWorkDir/jaguardatapaper/ID/X19.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 19],
main = 'Individual 19', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 19],
na.rm = T), main = 'Individual 19')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 19 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 19',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X20
unstacked <- split(move.data)
X20=unstacked$X20
X20_df <- as(X20, "data.frame")
head(X20_df)
nrow(X20_df)
range(X20_df$date)
m <- get_map(bbox(extent(X20)*1.1), source="google", zoom=10, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X20_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X20)*1.1), source="google", zoom=11, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X20_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X20_df, plot3d(x,y,date, type="l", col=as.numeric(X20_df$Event_ID)))
(stcube<-with(X20_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X20_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X20, units="mins"))
head(timeLag(X20, units="hours"))
median(timeLag(X20, units="hours"))
max(timeLag(X20, units="hours"))
max(timeLag(X20, units="days"))
plot(X20_df$individual.local.identifier..ID.~X20_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X20,file="c:/RWorkDir/jaguardatapaper/ID/X20.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 20],
main = 'Individual 20', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 20],
na.rm = T), main = 'Individual 20')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 20 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 20',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X21
unstacked <- split(move.data)
X21=unstacked$X21
X21_df <- as(X21, "data.frame")
head(X21_df)
nrow(X21_df)
range(X21_df$date)
m <- get_map(bbox(extent(X21)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X21_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X21)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X21_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X21_df, plot3d(x,y,date, type="l", col=as.numeric(X21_df$Event_ID)))
(stcube<-with(X21_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X21_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X21, units="mins"))
head(timeLag(X21, units="hours"))
median(timeLag(X21, units="hours"))
max(timeLag(X21, units="hours"))
max(timeLag(X21, units="days"))
plot(X21_df$individual.local.identifier..ID.~X21_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X21,file="c:/RWorkDir/jaguardatapaper/ID/X21.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 21],
main = 'Individual 21', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 21],
na.rm = T), main = 'Individual 21')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 21 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 21',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X22
unstacked <- split(move.data)
X22=unstacked$X22
X22_df <- as(X22, "data.frame")
head(X22_df)
nrow(X22_df)
range(X22_df$date)
m <- get_map(bbox(extent(X22)*1.1), source="google", zoom=12, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X22_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
m <- get_map(bbox(extent(X22)*1.1), source="google", zoom=13, maptype="satellite") #define the box for map based on the trajectory coordinates
ggmap(m)+geom_path(data=X22_df,aes(x=x, y=y),colour = "red") #plot the map and the trajectory
#' ## Display space-time cube.
open3d()
# To get a bigger window than the default
par3d(windowRect = c(100, 100, 612, 612))
Sys.sleep(0.1) # Allow sluggish window managers to catch up
with(X22_df, plot3d(x,y,date, type="l", col=as.numeric(X22_df$Event_ID)))
(stcube<-with(X22_df, plot3d(x,y,date, type="l",col=as.numeric(cut(X22_df$dist,3)), alpha=0.4)))
#Timelag
head(timeLag(X22, units="mins"))
head(timeLag(X22, units="hours"))
median(timeLag(X22, units="hours"))
max(timeLag(X22, units="hours"))
max(timeLag(X22, units="days"))
plot(X22_df$individual.local.identifier..ID.~X22_df $date,xlab = "Sampling period",ylab = "Individuals ID Number")
#write.table(X22,file="c:/RWorkDir/jaguardatapaper/ID/X22.txt",row.names = F,quote=F,col.names=T,sep="\t")
#Histograms and plots
hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 22],
main = 'Individual 22', xlab = "Time between fixes (h)")
plot(density.default(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 22],
na.rm = T), main = 'Individual 22')
breaks <- c(0, 0.5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 64.5, 128.5, 256.5, 1000)
breaks <- c(0, 1, 2*(1:256))
hh <- hist(mov.data.diff$time.diff[mov.data.diff$individual.local.identifier..ID. == 22 &
mov.data.diff$time.diff > 0 &
mov.data.diff$time.diff < 512],
main = 'Individual 22',xlab = 'Time between fixes (h)',
plot = T, breaks = breaks)
#X23
unstacked <- split(move.data)
X23=unstacked$X23