Main Process for
toyoichi_1
first step
- Toyota rent car with Ichigojam and GPS module
- Data sending to SAKURA internet through 3G + LTE antenna
- read data as csv file from SAKURA internet
library(tidyverse)
options(max.print=999999)# for long data
curl <- "http://mixsoda.io:2048/nu_toyota_1.csv?from=-604800"
cdestfile <- "/home/mother/jun/ikeda/20230615-17pm.csv"
download.file(curl,cdestfile)
toyota <- read.csv(file = "/home/mother/jun/ikeda/20230615-17pm.csv")
Second step
- GPS data process each 3 minutes
- time data process
- latitude data process
- longitude data process
toyota_separate <-
toyota %>%
separate(
col = data,
into = c("time1", "first","second","third","forth","fifth"),
sep = "a"
)
time1 <-
as.POSIXct(
(as.integer(str_sub(toyota_separate$time1,start = 1, end = 2))*3600)
+(as.integer(str_sub(toyota_separate$time1,start = 3, end = 4))*60)
+(as.integer(str_sub(toyota_separate$time1,start = 5, end = 6))+1685232000),
origin = '1970-01-01', tz="Japan")
time2 <-
as.POSIXct(
(as.integer(str_sub(toyota_separate$first,start = 18, end = 19))*3600)
+(as.integer(str_sub(toyota_separate$first,start = 20, end = 21))*60)
+(as.integer(str_sub(toyota_separate$first,start = 22, end = 23))+1685232000),
origin = '1970-01-01', tz="Japan")
time3 <-
as.POSIXct(
(as.integer(str_sub(toyota_separate$second,start = 18, end = 19))*3600)
+(as.integer(str_sub(toyota_separate$second,start = 20, end = 21))*60)
+(as.integer(str_sub(toyota_separate$second,start = 22, end = 23))+1685232000),
origin = '1970-01-01', tz="Japan")
time4 <-
as.POSIXct(
(as.integer(str_sub(toyota_separate$third,start = 18, end = 19))*3600)
+(as.integer(str_sub(toyota_separate$third,start = 20, end = 21))*60)
+(as.integer(str_sub(toyota_separate$third,start = 22, end = 23))+1685232000),
origin = '1970-01-01', tz="Japan")
time5 <-
as.POSIXct(
(as.integer(str_sub(toyota_separate$forth,start = 18, end = 19))*3600)
+(as.integer(str_sub(toyota_separate$forth,start = 20, end = 21))*60)
+(as.integer(str_sub(toyota_separate$forth,start = 22, end = 23))+1685232000),
origin = '1970-01-01', tz="Japan")
ido1 <- as.integer(str_sub(toyota_separate$first,start = 1, end = 2))
ido11 <- as.integer(str_sub(toyota_separate$first,start = 3, end = 8))
ido1 <- ido1+(ido11/10000/60)
ido2 <- as.integer(str_sub(toyota_separate$second,start = 1, end = 2))
ido22 <- as.integer(str_sub(toyota_separate$second,start = 3, end = 8))
ido2 <- ido2+(ido22/10000/60)
ido3 <- as.integer(str_sub(toyota_separate$third,start = 1, end = 2))
ido33 <- as.integer(str_sub(toyota_separate$third,start = 3, end = 8))
ido3 <- ido3+(ido33/10000/60)
ido4 <- as.integer(str_sub(toyota_separate$forth,start = 1, end = 2))
ido44 <- as.integer(str_sub(toyota_separate$forth,start = 3, end = 8))
ido4 <- ido4+(ido44/10000/60)
ido5 <- as.integer(str_sub(toyota_separate$fifth,start = 1, end = 2))
ido55 <- as.integer(str_sub(toyota_separate$fifth,start = 3, end = 8))
ido5 <- ido5+(ido55/10000/60)
kdo1 <- as.integer(str_sub(toyota_separate$first,start = 9, end = 11))
kdo11 <- as.integer(str_sub(toyota_separate$first,start = 12, end = 17))
kdo1 <- kdo1+(kdo11/10000/60)
kdo2 <- as.integer(str_sub(toyota_separate$second,start = 9, end = 11))
kdo22 <- as.integer(str_sub(toyota_separate$second,start = 12, end = 17))
kdo2 <- kdo2+(kdo22/10000/60)
kdo3 <- as.integer(str_sub(toyota_separate$third,start = 9, end = 11))
kdo33 <- as.integer(str_sub(toyota_separate$third,start = 12, end = 17))
kdo3 <- kdo3+(kdo33/10000/60)
kdo4 <- as.integer(str_sub(toyota_separate$forth,start = 9, end = 11))
kdo44 <- as.integer(str_sub(toyota_separate$forth,start = 12, end = 17))
kdo4 <- kdo4+(kdo44/10000/60)
kdo5 <- as.integer(str_sub(toyota_separate$fifth,start = 9, end = 11))
kdo55 <- as.integer(str_sub(toyota_separate$fifth,start = 12, end = 17))
kdo5 <- kdo5+(kdo55/10000/60)
Third step
- time and latitude and longitude data merging each term
- finally, total data was merged.
allData1 <- cbind(time1,ido1,kdo1)
allData2 <- cbind(time2,ido2,kdo2)
allData3 <- cbind(time3,ido3,kdo3)
allData4 <- cbind(time4,ido4,kdo4)
allData5 <- cbind(time5,ido5,kdo5)
allData <- rbind(allData1,allData2,allData3,allData4,allData5)
head(toyota)
## utc iccid
## 1 1686222794 8.98104e+18
## 2 1686222840 8.98104e+18
## 3 1686222855 8.98104e+18
## 4 1686222869 8.98104e+18
## 5 1686222884 8.98104e+18
## 6 1686222899 8.98104e+18
## data
## 1 111301a32510308129497112111304a32510305129497111111307a32510305129497111111309a32510304129497111111312a325103031294971127c123400
## 2 111345a32510298129497111111348a32510298129497111111351a32510301129497105111354a32510299129497087111357a325102691294970537c123400
## 3 111400a32510219129497000111403a32510189129496966111406a32510179129496953111409a32510173129496945111412a325101701294969427c123400
## 4 111415a32510171129496943111418a32510171129496943111421a32510171129496943111424a32510171129496943111427a325101671294969387c123400
## 5 111430a32510124129496946111433a32510046129497041111436a32509928129497191111439a32509787129497369111442a325096381294975527c123400
## 6 111445a32509474129497717111448a32509276129497869111451a32509053129498007111454a32508816129498146111457a325085821294982827c123400
tail(toyota)
## utc iccid
## 3523 1686824036 8.98104e+18
## 3524 1686824050 8.98104e+18
## 3525 1686824065 8.98104e+18
## 3526 1686824082 8.98104e+18
## 3527 1686824095 8.98104e+18
## 3528 1686824110 8.98104e+18
## data
## 3523 101341a32474681129516313101344a32474681129516311101347a32474675129516313101350a32474627129516338101353a324745661295163667c123400
## 3524 101356a32474480129516399101359a32474369129516446101402a32474229129516494101405a32474080129516546101408a324739421295165977c123400
## 3525 101411a32473797129516649101414a32473643129516693101417a32473486129516744101420a32473324129516798101423a324731521295168657c123400
## 3526 101426a32472981129516936101429a32472834129516999101432a32472696129517048101435a32472537129517097101438a324723601295171527c123400
## 3527 101441a32472189129517203101444a32472029129517257101447a32471878129517310101450a32471737129517360101453a324715841295174127c123400
## 3528 101456a32471444129517460101459a32471379129517498101502a32471370129517550101505a32471367129517611101508a324713811295176817c123400
head(toyota_separate)
## utc iccid time1 first second
## 1 1686222794 8.98104e+18 111301 32510308129497112111304 32510305129497111111307
## 2 1686222840 8.98104e+18 111345 32510298129497111111348 32510298129497111111351
## 3 1686222855 8.98104e+18 111400 32510219129497000111403 32510189129496966111406
## 4 1686222869 8.98104e+18 111415 32510171129496943111418 32510171129496943111421
## 5 1686222884 8.98104e+18 111430 32510124129496946111433 32510046129497041111436
## 6 1686222899 8.98104e+18 111445 32509474129497717111448 32509276129497869111451
## third forth fifth
## 1 32510305129497111111309 32510304129497111111312 325103031294971127c123400
## 2 32510301129497105111354 32510299129497087111357 325102691294970537c123400
## 3 32510179129496953111409 32510173129496945111412 325101701294969427c123400
## 4 32510171129496943111424 32510171129496943111427 325101671294969387c123400
## 5 32509928129497191111439 32509787129497369111442 325096381294975527c123400
## 6 32509053129498007111454 32508816129498146111457 325085821294982827c123400
tail(toyota_separate)
## utc iccid time1 first
## 3523 1686824036 8.98104e+18 101341 32474681129516313101344
## 3524 1686824050 8.98104e+18 101356 32474480129516399101359
## 3525 1686824065 8.98104e+18 101411 32473797129516649101414
## 3526 1686824082 8.98104e+18 101426 32472981129516936101429
## 3527 1686824095 8.98104e+18 101441 32472189129517203101444
## 3528 1686824110 8.98104e+18 101456 32471444129517460101459
## second third forth
## 3523 32474681129516311101347 32474675129516313101350 32474627129516338101353
## 3524 32474369129516446101402 32474229129516494101405 32474080129516546101408
## 3525 32473643129516693101417 32473486129516744101420 32473324129516798101423
## 3526 32472834129516999101432 32472696129517048101435 32472537129517097101438
## 3527 32472029129517257101447 32471878129517310101450 32471737129517360101453
## 3528 32471379129517498101502 32471370129517550101505 32471367129517611101508
## fifth
## 3523 324745661295163667c123400
## 3524 324739421295165977c123400
## 3525 324731521295168657c123400
## 3526 324723601295171527c123400
## 3527 324715841295174127c123400
## 3528 324713811295176817c123400
head(allData)
## time1 ido1 kdo1
## [1,] 1685272381 32.85051 129.8285
## [2,] 1685272425 32.85050 129.8285
## [3,] 1685272440 32.85036 129.8283
## [4,] 1685272455 32.85028 129.8282
## [5,] 1685272470 32.85021 129.8282
## [6,] 1685272485 32.84912 129.8295
tail(allData)
## time1 ido1 kdo1
## [17635,] 1685268833 32.79094 129.8606
## [17636,] 1685268848 32.78990 129.8610
## [17637,] 1685268863 32.78859 129.8614
## [17638,] 1685268878 32.78727 129.8619
## [17639,] 1685268893 32.78597 129.8624
## [17640,] 1685268908 32.78563 129.8628
Forth step
- data sorting process on time region
- write data on disk as csv file
#library(dplyr)
allData <- as.data.frame(allData)# Needs for the sort process changing as.data.frame
allDataFinal <- allData[order(allData$time1),]#ascending, if descending (-time1)
head(allData)
## time1 ido1 kdo1
## 1 1685272381 32.85051 129.8285
## 2 1685272425 32.85050 129.8285
## 3 1685272440 32.85036 129.8283
## 4 1685272455 32.85028 129.8282
## 5 1685272470 32.85021 129.8282
## 6 1685272485 32.84912 129.8295
tail(allData)
## time1 ido1 kdo1
## 17635 1685268833 32.79094 129.8606
## 17636 1685268848 32.78990 129.8610
## 17637 1685268863 32.78859 129.8614
## 17638 1685268878 32.78727 129.8619
## 17639 1685268893 32.78597 129.8624
## 17640 1685268908 32.78563 129.8628
head(allDataFinal)
## time1 ido1 kdo1
## 8718 1685232000 32.78548 129.8670
## 9529 1685232001 33.59243 130.4099
## 12246 1685232003 32.78562 129.8672
## 13057 1685232004 33.59247 130.4098
## 15774 1685232006 32.78578 129.8674
## 16585 1685232007 33.59256 130.4097
tail(allDataFinal)
## time1 ido1 kdo1
## 1662 1685318394 32.78536 129.8668
## 2473 1685318395 33.59236 130.4102
## 5190 1685318397 32.78538 129.8668
## 6001 1685318398 33.59240 130.4101
## 8825 NA NA 100.0075
## 12353 NA 33.03480 129.9265
write.csv(allDataFinal,file = "/home/mother/jun/ikeda/20230615-17pmFinal.csv")