Convert lat/lon to zipcode / neighborhood name

走远了吗. 提交于 2019-11-30 09:50:25

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

Use Reverse Geocoding to convert your lat/lon to addresses. It has some limit on the number of queries per day though.

Here is a nice blog post with examples how to geocode and reverse geocode using google-maps.

Try this one:

http://www.usnaviguide.com/zip.htm

There is some limit as to how many queries per day you can do on the site, but they also sell the complete database, which changes every few months. Sorry that I don't know of any free resources.

As others suggested, geocode them into street address should work fine for zip code. i am not too sure about neighborhood, because you may have to look if street number is odd/even to see if it is located which side of a road that determines neighborhood.

An alternative way is to prepare GIS polygon feature (ESRI shape file for example), test each point against this set of polygons see which one it intersects.

zip code is very straighforward, you can download shape file from the census.

http://www.census.gov/cgi-bin/geo/shapefiles2010/main

neighborhood is harder, i'd guess. In another part of US i had to create my shape file on my own by combining definitions from municipal government, real-estate website, newspaper etc so that it looks like what people thinks neighborhood in the city are without having any overlap or gap. It can take some time to compose such set of polygons. you may crab census "block group", or even census "block" from the above page and merge them

Once you prepared polygon features, there are couple of GIS tools on different environment (stand-alone executable, GUI program, c/python/sql etc API, probably R as well, to do intersection of polygons and points.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!