r - Finding closest point between two vectors based on two dimensions
问题描述
I have two matrices with large amounts of gps data:
- User Based GPS Data for each user i ((Latitude_i, Longitude_i), ...)) ~ 12 Mio GPS Coordinates
- Store Based GPS Data for each store j ((Latitude_j, Longitude_j), ..)) ~ 15 k GPS Coordinates
What I need ultimately is the closest store j (from 2.) for each user i (from 1.).
The brut force (but computationally not feasible) solution would be, to calculate the geographical distance between each user i (from 1.) and each store j from (2.) and then take the lowest distance.
- Since this would result in a 12 Mio x 15 k matrix and I do not have access to a Big Data infrastructure, this is not really working for me.
So I am looking for smart solutions right now.
- What crossed my mind so far, was the idea of finding the simple numerically closest point between each user i (1.) and each store j (2.)
using apply and which.min(abs(lat_i-lat_j) + abs(long_i + long_j))
and then calculate the geographical distance between these two points.
- However, the challenge here is that I need a function that minimizes the overall difference, consisting of two points and the above solution doesnt seem to work.
- Any help is very much appreciated!!
解决方案
推荐阅读
- python - 在 S3 中使用 conda-index
- vuejs2 - vue.js - 方法不能迭代数组属性
- nginx - LXC 容器的 NGINX 反向代理
- python - scrapy登录后怎么爬?
- ios - 如何让 iPhone/iPad 完全忘记 App 的媒体授权状态?
- mysql - 为什么我的最高薪水查询有语法错误?
- java - Spring Boot 2 - 内存缓存
- javascript - 这在 javascript 中是什么,它有什么意义?
- swift - 当另一个事件发出时如何从一个可观察的事件中提取一个事件
- python - 使用 FontForge 从 PNG/SVG 文件生成 TTF