views:

1464

answers:

8

Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location.

(This is similar to http://stackoverflow.com/questions/23572/latitude-longitude-database, except I want to convert in the opposite direction.)


Related question: http://stackoverflow.com/questions/158557/get-street-address-at-latlong-pair

+2  A: 

This is the web service to call. http://developer.yahoo.com/search/local/V2/localSearch.html

This site has ok web services, but not exactly what you're asking for here. http://www.usps.com/webtools/

Dana
+1  A: 

If you call volume to the service gets up too high, you should definitely consider getting your own set of postal data. In most cases, that will provide all of the information that you need, and there are plenty of db tools for indexing location data (i.e. PostGIS for PostgreSQL).

Dana the Sane
+1  A: 

You can buy a fairly inexpensive subscription to zipcodes with lat and long info here: http://www.zipcodedownload.com/

Geri Langlois
+3  A: 

Any of the online services mentioned and their competitors offer "reverse geocoding" which does what you ask--convert lon/lat coordinates into a street address of some-sort.

If you only need the zip codes and/or cities, then I would obtain the Zip Code database and urban area database from the US Census Bureau which is FREE (paid for by your tax dollars). http://www.census.gov/geo/www/cob/zt_metadata.html.

From there, you can either come up with your own search algorithm for the spatial data or make use of one of a spatial databases such as Microsoft SQL Server, PostGIS, Oracle Spatial, ArcSDE, etc.

James Schek
A: 

geonames has an extensive set of ws that can handle this (among others):

http://www.geonames.org/export/web-services.html#findNearbyPostalCodes
http://www.geonames.org/export/web-services.html#findNearbyPlaceName

coldfusionPaul
A: 

Another reverse geocoding provider that hasn't been listed here yet is OpenStreetMap: use a lat,long as a NameFinder query to get quite extensive XML information about that location.

OSM has the (potentially?) added bonus of being entirely user editable (wiki-like) and thus having a very liberal licencing scheme of all this data. Think of this of open source map data.

peSHIr
+1  A: 

Or google's reverse geocoding

link

http://maps.google.com/maps/geo?output=xml&q={0},{1}&key={2}&sensor=true&oe=utf8

where 0 is latitude 1 is longitude

bob
A: 

Be aware that the USPS updates their ZIP databases monthly. http://www.semaphorecorp.com is a cheap source of ZIP and geo data.

joe snyder

related questions