Skip to content

geolife example #1

@mdsumner

Description

@mdsumner
library(trip)

dp <- "geolife/Geolife Trajectories 1.3/Data"
fs <- list.files(dp, pattern = "plt$", full.names = TRUE, recursive = TRUE)
readLines(fs[1], n = 10)
library(readr)
library(dplyr)
read_csv(x,  col_names = c("lat", "lon", "zero", "altitude", "date1", "date2", "time"))

system.time({
d <- bind_rows(lapply(fs, read_csv, 
                      col_names = c("lat", "lon", "zero", "altitude", "date1", "date2", "time"), 
                      col_types = cols(lat = "d", lon = "d", zero = "i", altitude = "d", date1 = "d", date2 = "c", time = "c"), 
                      skip = 6))
})
# user  system elapsed 
#492.344 110.476 644.266 

d$utc <- as.POSIXct(strptime(paste(d$date2, d$time), "%Y-%m-%d %H:%M:%S"),  tz = "UTC")
saveRDS(d, file = "geolife.rds", compress = "xz")
d <- readRDS("geolife.rds")
idx  <- seq(1, nrow(d), length = 1e6)
d <- d[idx, ]

library(palr)
library(viridis)
tpal <- mk_timePal(d$utc, col = viridis::viridis(64))

library(rgdal)
xy <- project(cbind(d$lon, d$lat), "+proj=laea +lon_0=140")
library(maptools)
data(wrld_simpl)
m <- spTransform(wrld_simpl, "+proj=laea +lon_0=140")

plot(xy, pch = ".", col = tpal(d$utc))
plot(m, add = FALSE)
points(xy, pch = ".", col = tpal(d$utc))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions