【发布时间】:2021-02-24 20:22:16
【问题描述】:
structure(list(trip_count = 1:10, pickup_longitude = c(-73.964096,
-73.989037, -73.934998, -73.93409, -73.998222, -74.004478, -73.994881,
-73.955917, -73.993607, -73.948265), pickup_latitude = c(40.764141,
40.760208, 40.746693, 40.715908, 40.750809, 40.741501, 40.74033,
40.776054, 40.758625, 40.778515)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
所以我正在尝试将经度和纬度数据重新编码为纽约市的邮政编码。
使用revgeocodingfrom ggmap 我已经得到了一些结果:
res <- revgeocode(c(test$pickup_longitude[1],test$pickup_latitude[1]), output = "all")
然而,
- 我可以一次只将此过程应用于一个位置数据。有没有一种方法可以一次获得每个位置的结果,例如
res <- revgeocode(c(test$pickup_longitude,test$pickup_latitude), output = "all")
解决方案不必在ggmap 中工作,也许有不同的方法可以从经度和纬度数据中获取邮政编码?
谢谢!
【问题讨论】:
-
你能显示来自
revgeocode的示例输出吗?我没有有效的 API 密钥。 -
sapply(data.frame(t(df[2:3])), revgeocode, output='all')应该可以工作。虽然可能revgeocode确实需要一个矩阵