I have questions related with GPS data. I have data looks like

The question is, I want to extract information from that data to the value3, I want to fill value3 with "steady" and "moving".
steady and moving based on values from latitude and longitude, but I also still confused because when I tried to plot.
The example :
35.1754255,126.9130674
35.1754281,126.9130184
35.1754225,126.9130536
35.1807405,126.9055772
The result of plot:

Values 1 ~ 3 are moving but just only little moving not much, so maybe the value3 will be fill with "steady", "short moving", "long moving" but I am still do not know about the threshold values to define which is short, and long.
My second question is how I can generate the value3 using R code. Actually I can compare the next values and the current values, if different means moving, if not means steady, but I am still confused about short and long moving.
The Output of dput() from my data
> dput(loc)
structure(list(time = c("2014-06-30 08:26:36", "2014-06-30 08:31:30",
"2014-06-30 08:36:30", "2014-06-30 08:41:30", "2014-06-30 08:46:30",
"2014-06-30 08:51:30", "2014-06-30 08:56:31", "2014-06-30 09:01:30",
"2014-06-30 09:06:30", "2014-06-30 09:11:30", "2014-06-30 09:16:30",
"2014-06-30 09:21:30", "2014-06-30 09:26:30", "2014-06-30 09:31:30",
"2014-06-30 09:36:30", "2014-06-30 09:41:30", "2014-06-30 09:46:30",
"2014-06-30 09:51:52", "2014-06-30 09:56:30", "2014-06-30 10:01:30",
"2014-06-30 10:06:53", "2014-06-30 10:11:30", "2014-06-30 10:16:52",
"2014-06-30 10:21:30", "2014-06-30 10:26:30", "2014-06-30 10:31:30",
"2014-06-30 10:36:51", "2014-06-30 10:41:30", "2014-06-30 10:46:54",
"2014-06-30 10:51:51", "2014-06-30 10:57:30", "2014-06-30 11:01:51",
"2014-06-30 11:06:30", "2014-06-30 11:11:51", "2014-06-30 11:16:30",
"2014-06-30 11:21:51", "2014-06-30 11:26:30", "2014-06-30 11:31:30",
"2014-06-30 11:36:52", "2014-06-30 11:41:30", "2014-06-30 11:46:51",
"2014-06-30 11:51:30", "2014-06-30 11:56:53", "2014-06-30 12:01:32",
"2014-06-30 12:07:30", "2014-06-30 12:11:51", "2014-06-30 12:16:33",
"2014-06-30 12:21:30", "2014-06-30 12:26:30", "2014-06-30 12:31:51",
"2014-06-30 12:36:30", "2014-06-30 12:41:36", "2014-06-30 12:46:30",
"2014-06-30 12:52:10", "2014-06-30 12:56:30", "2014-06-30 13:01:30",
"2014-06-30 13:06:30", "2014-06-30 13:11:30", "2014-06-30 13:16:30",
"2014-06-30 13:21:30", "2014-06-30 13:26:30", "2014-06-30 13:31:30",
"2014-06-30 13:36:30", "2014-06-30 13:41:30", "2014-06-30 13:46:30",
"2014-06-30 13:51:30", "2014-06-30 13:56:30", "2014-06-30 14:01:30",
"2014-06-30 14:06:55", "2014-06-30 14:11:19", "2014-06-30 14:16:19",
"2014-06-30 14:21:19", "2014-06-30 14:26:19", "2014-06-30 14:31:19",
"2014-06-30 14:36:19", "2014-06-30 14:41:19", "2014-06-30 14:46:19",
"2014-06-30 14:51:19", "2014-06-30 14:56:19", "2014-06-30 15:01:19",
"2014-06-30 15:06:19", "2014-06-30 15:11:19", "2014-06-30 15:16:19",
"2014-06-30 15:21:19", "2014-06-30 15:26:19", "2014-06-30 15:31:19",
"2014-06-30 15:36:19", "2014-06-30 15:41:19", "2014-06-30 15:46:19",
"2014-06-30 15:51:19", "2014-06-30 15:56:19", "2014-06-30 16:01:19",
"2014-06-30 16:06:19", "2014-06-30 16:11:19", "2014-06-30 16:16:20",
"2014-06-30 16:21:19", "2014-06-30 16:26:19", "2014-06-30 16:31:19",
"2014-06-30 16:36:19", "2014-06-30 16:41:19"), type = c("location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location", "location", "location", "location",
"location", "location", "location"), value1 = c("35.1754255",
"35.1754281", "35.1754225", "35.1753982", "35.1753991", "35.1753997",
"35.1754333", "35.1754143", "35.1754126", "35.1754142", "35.1753987",
"35.1754178", "35.1754176", "35.1753914", "35.1754066", "35.1753833",
"35.1753883", "35.174465", "35.174465", "35.1735813", "35.1744781",
"35.1735813", "35.174502", "35.1749091", "35.1749091", "35.1749091",
"35.1744991", "35.1749091", "35.1751931", "35.1748972", "35.1755879",
"35.1759928", "35.1759928", "35.1763946", "35.1763946", "35.1763882",
"35.1763882", "35.1762131", "35.1760547", "35.1760547", "35.1774352",
"35.1774352", "35.1785821", "35.1785821", "35.1773562", "35.1807058",
"35.1807058", "35.1813436", "35.1802903", "35.1807615", "35.1807615",
"35.1807405", "35.1807405", "35.1805536", "35.1805536", "35.1808169",
"35.1797636", "35.1836812", "35.1836812", "35.1897643", "35.1898214",
"35.1897615", "35.1897765", "35.1897157", "35.1896921", "35.1897299",
"35.18975", "35.1897503", "35.1897673", "35.1897539", "35.1897932",
"35.1897702", "35.1897627", "35.189763", "35.1897438", "35.1898021",
"35.1897853", "35.1897405", "35.1897803", "35.1897844", "35.1897624",
"35.1897769", "35.1897656", "35.1897265", "35.1897488", "35.1897599",
"35.1897477", "35.1897951", "35.189759", "35.1897624", "35.1897692",
"35.1898468", "35.1897727", "35.1897624", "35.1897958", "35.189817",
"35.1897391", "35.1897317", "35.189745", "35.1897624"), value2 = c("126.9130674",
"126.9130184", "126.9130536", "126.9130597", "126.9130549", "126.9130598",
"126.9130484", "126.9130638", "126.9130687", "126.9130553", "126.913074",
"126.9130686", "126.9130779", "126.9130496", "126.9130196", "126.9130507",
"126.9130474", "126.9135807", "126.9135807", "126.9119189", "126.9137426",
"126.9119189", "126.9137499", "126.9124954", "126.9124954", "126.9124954",
"126.9137861", "126.9124954", "126.9142743", "126.9118689", "126.912267",
"126.9131502", "126.9131502", "126.9130495", "126.9130495", "126.9131069",
"126.9131069", "126.911819", "126.9121906", "126.9121906", "126.9123621",
"126.9123621", "126.9093961", "126.9093961", "126.9041179", "126.9055765",
"126.9055765", "126.904599", "126.9054961", "126.905568", "126.905568",
"126.9055772", "126.9055772", "126.9052718", "126.9052718", "126.9050475",
"126.9059447", "126.9052348", "126.9052348", "126.9063181", "126.9062802",
"126.9063452", "126.9064237", "126.9065031", "126.9065168", "126.9063599",
"126.9064195", "126.9064469", "126.9063441", "126.9063828", "126.9064423",
"126.9063459", "126.9063602", "126.9063096", "126.9063355", "126.9063742",
"126.9063253", "126.9063123", "126.9063434", "126.9063729", "126.906397",
"126.9063288", "126.906282", "126.9062903", "126.9063502", "126.9063432",
"126.9063004", "126.9063742", "126.9063343", "126.9063969", "126.9062847",
"126.9063212", "126.9063034", "126.9063969", "126.9063237", "126.906375",
"126.9063572", "126.9063514", "126.9062548", "126.906397"), value3 = c("",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "")), .Names = c("time", "type", "value1", "value2",
"value3"), row.names = c(NA, 100L), class = "data.frame")
Here is my attempt. As I mentioned in the comments above, you want to define "short movement" and "long movement" by yourself. In R, you can use lag() in the dplyr package and calculate movement, for instance. I may be wrong, but 1 degree is about 111.32 km. So 0.0001 degree is about 11 meters. In this attempt, if this person moved more than 11 meters and less than 55 meters in both longitude and latitude, I considered the movement "little movement". Any longer movement is considered "long movement". Since I am not a gis professional, my approach may not be appropriate. But, I hope this gives you some ideas of what you would want to do.
P.S. If you have a large data, this ifelse() will slow down the process. You want to consider using the data.table package.
# Note: 1 degree = 111.32 km
#0.0001 degree 11.1132 m
# Convert character to numeric
mydf$value1 <- as.numeric(mydf$value1)
mydf$value2 <- as.numeric(mydf$value2)
library(dplyr)
select(mydf, -type, -value3) %>%
mutate(movement = ifelse(value1 == lag(value1) & value2 == lag(value2), "same",
ifelse(between(abs(value1 - lag(value1)), 0.0001, 0.0005) == TRUE &
between(abs(value2 - lag(value2)), 0.0001, 0.0005) == TRUE, "little", "long")))
# A part of the outcome
#33 2014-06-30 11:06:30 35.175993 126.91315 same
#34 2014-06-30 11:11:51 35.176395 126.91305 little
#35 2014-06-30 11:16:30 35.176395 126.91305 same
#36 2014-06-30 11:21:51 35.176388 126.91311 long
#37 2014-06-30 11:26:30 35.176388 126.91311 same
#38 2014-06-30 11:31:30 35.176213 126.91182 long
#39 2014-06-30 11:36:52 35.176055 126.91219 little
#40 2014-06-30 11:41:30 35.176055 126.91219 same
#41 2014-06-30 11:46:51 35.177435 126.91236 long
#42 2014-06-30 11:51:30 35.177435 126.91236 same
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With