将经纬度转换为邮政编码/邻居名称 [英] Convert lat/lon to zipcode / neighborhood name

查看:212
本文介绍了将经纬度转换为邮政编码/邻居名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量GPS位置的图片集,编码为纬度/经度坐标,主要集中在洛杉矶。我想将这些转换为(1)邮编和(2)邻居名称。有没有免费的网络服务或数据库可以这样做?



到目前为止我所能想到的最好的办法是从洛杉矶时间页面,并尝试找出每个坐标所在的多边形。然而,这可能是相当多的工作,并不是所有的坐标都在洛杉矶。至于邮编,这个2004 数据库是我能找到的最好的,但是邮编被编码为一个单一的坐标而不是多边形。所以我能做的最好的是找到从给定坐标到给定的邮政编码坐标的最小距离,这是不理想的。



我的印象是,google-地图或开放式街道地图应该可以做到这一点(因为他们似乎'知道'每个邻居和邮政编码的确切位置),但我找不到任何API来执行查找/查询。$ b $你现在可以直接在R本身内做到这一点,这要归功于相当棒的ggmap 包。

与其他人一样,您将使用Google地图API进行反向地理编码(因此每天限制在2,500个查询中),但它很简单:

  library(ggmap)

#生成单个示例地址
lonlat_sample< - as.numeric(geocode(hollyood bowl))
lonlat_sample#注意该订单是经度,latitiude

res < - 重新vgeocode(lonlat_sample,output =more)
#然后可以访问zip和附近的地方填充
res $ postal_code
res $ neighborhood


I have a large collection of pictures with GPS locations, encoded as lat/lon coordinates, mostly in Los Angeles. I would like to convert these to (1) zipcodes, and (2) neighborhood names. Are there any free web services or databases to do so?

The best I can come up with so far is scrape the neighborhood polygons from the LA times page and try to find out in which polygon every coordinate is. However this might be quite a lot of work, and not all of my coordinates are in LA. As for the zipcodes, this 2004 database is the best I can find, however zipcodes are encoded as a single coordinates instead of a polygon. So the best I can do is find the minimum distance from a given coordinate to the given zipcode-coordinates, which is not optimal.

I was under the impression that google-maps or open-street-maps should be able to do this (as they seem to 'know' exactly where every neighboorhood and zipcode is), however I cannot find any API's to do the lookups / queries.

解决方案

You can now do this directly within R itself thanks to the rather awesome ggmap package.

Like others mention, you'll be reverse geocoding using the google maps API (and therefore limited to 2,500 queries daily), but it's as simple as:

library("ggmap")

# generate a single example address
lonlat_sample <- as.numeric(geocode("the hollyood bowl"))
lonlat_sample  # note the order is longitude, latitiude

res <- revgeocode(lonlat_sample, output="more")
# can then access zip and neighborhood where populated
res$postal_code
res$neighborhood

这篇关于将经纬度转换为邮政编码/邻居名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆