在彼此相愛以前,我們是否就曾在街頭的一隅錯身而過好幾次?Google地圖的數據分析應用

2022 10 10 130542 | 吹著魔笛的浮士德

Advertisement

「與你相遇的結果是否是命運注定的安排?」

因為想要知道自己與男朋友在正式交往以前,倆人究竟是否曾經有過擦身而過的經驗,海外資料分析師 Channon Perry 透過 Google 地圖的 GPS 歷史數據,分析了倆人的移動歷史,最終得出有趣的結果,其實倆人在交往前就曾經錯身而過 33 次

「How fateful?」
https://chan.co.za/how-fateful

當我遇到我的男朋友時,有時會感到一絲遺憾,儘管我們在同一個城市生活了五年,在同一所大學上學,但卻從來沒有機會講述一個可愛的邂逅故事。我們相識的故事在 2020 年的許多情侶中並不少見的——在 COVID 浪潮之間的低谷中,我們開始在約會 APP Bumble 上聊天。

多虧了 Google 在後台悄悄地收集 GPS 數據與位置歷史資料,讓我開始思考,有可能找出一個答案 – 「在相遇之前我們的人生是如何交錯的,以及我們彼此有多接近一個眼神交流的時刻。」

在 Google 的地圖資料中有四種精度的紀錄,分別是「111m」「11.1m」「1.11m」「0.111m」。

Channon Perry 利用「11.1m」的資料進行統計後發現資料數量實在太多,所以改用「111m」的數據來分析,最終結果如下圖所示。

02 m | 吹著魔笛的浮士德

黃色的足跡是 Perry 本人的移動歷程,而紅色則是男友的行動紀錄,接近藍色的區塊則是倆人都曾經造訪過的地方。

之後 Perry 再將倆人「相同時間、近距離」接觸的瞬間資料清洗出來,最終分析結果如下圖,倆人總計在城市中相遇了 33 次(完整大圖)。

04 m | 吹著魔笛的浮士德

Perry 除了展示這個有趣的結果以外,也在網頁上公布了他的算法,摘要部份如下,有興趣的不妨移步前往參考。

Finding minimum time intervals at the same locations

all_intervals <-
  seq(from = start_looking_from, to = best_day, by = "10 min") %>%
  as.data.frame()
colnames(all_intervals) <- "timestamp"

whole_time_x <-
  full_join(all_intervals, x_records, by = "timestamp") %>%
  mutate(person = x)

whole_time_y <-
  full_join(all_intervals, y_records, by = "timestamp") %>%
  mutate(person = y)

#I'm using the haversine formula to calculate the distance between two points on earth's spherical surface. This is because the harversine formula offers the most accuracy on the scale of meters.

haversine_calc <- function(lat.x, lat.y, lon.x, lon.y) {
  #radius of the earth in km
  r <- 6371
  
  #converting degrees to radians
  r.lat.x <- (lat.x * pi) / 180
  r.lat.y <- (lat.y * pi) / 180
  r.lon.x <- (lon.x * pi) / 180
  r.lon.y <- (lon.y * pi) / 180
  
  dlat <- r.lat.y - r.lat.x
  dlon <- r.lon.y - r.lon.x
  
  a <- sin(dlat / 2) ** 2 + cos(r.lat.x) * cos(r.lat.y) * sin(dlon / 2) **  2
  
  c <- 2 * asin(sqrt(a))
  
  d <- c * r
  
}

whole_time_both <-
  full_join(whole_time_x, whole_time_y, by = "timestamp") %>%
  filter(!is.na(coordinates.x)) %>%
  filter(!is.na(coordinates.y)) %>%
  mutate(
    distance = haversine_calc(
      lat.x = latitude.x,
      lat.y = latitude.y,
      lon.x = longitude.x,
      lon.y = longitude.y
    ) * 1000
  ) %>%
  arrange(distance)

whole_time_both$accuracy <-
  whole_time_both$accuracy.x + whole_time_both$accuracy.y

whole_time_simple <- whole_time_both %>%
  select(timestamp, distance, accuracy) %>%
  mutate(day = as.Date(timestamp)) %>%
  group_by(day) %>%
  transmute(min_dist = min(distance), min_acc = min(accuracy)) %>%
  mutate(closest_brush = (min_dist == 0)) %>%
  unique()

ggplot(whole_time_simple,
       aes(x = day, y = min_dist, color = closest_brush)) +
  geom_point(
    alpha = 0.5,
    position = "jitter",
    fill = "white",
    size = 3
  ) +
  scale_color_discrete(two_colors, name = "Closest brush?") +
  theme_classic() +
  labs(x = "Date",
       y = "Distance from each other (meters)", 
       title = "Distance apart over time") +
  ylim(0, 2500)

 

Source – 「交際相手と出会う前にすれ違った回数」をGoogleマップの位置情報履歴から求めた結果とは?

 

 點一下追蹤 IG 與吹著魔笛的浮士德粉絲團 🙏

追蹤 Instagram👍https://lihi3.cc/vlzV5

↓追蹤 Facebook 專頁↓