<p>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.</p>

<p>(This is similar to <a href="https://stackoverflow.com/questions/23572/latitude-longitude-database">https://stackoverflow.com/questions/23572/latitude-longitude-database</a>, except I want to convert in the opposite direction.)</p>

<hr>

<p>Related question: <a href="https://stackoverflow.com/questions/158557/get-street-address-at-latlong-pair">Get street address at lat/long pair</a></p>

[{'answer_id': 30965, 'author': 'coder1', 'author_id': 3018, 'author_profile': 'https://Stackoverflow.com/users/3018', 'pm_score': 3, 'selected': True, 'text': '<p>This is the web service to call.\n<a href="http://developer.yahoo.com/search/local/V2/localSearch.html" rel="nofollow noreferrer">http://developer.yahoo.com/search/local/V2/localSearch.html</a></p>\n\n<p>This site has ok web services, but not exactly what you\'re asking for here.\n<a href="http://www.usps.com/webtools/" rel="nofollow noreferrer">http://www.usps.com/webtools/</a></p>\n'}, {'answer_id': 31330, 'author': 'Dana the Sane', 'author_id': 2567, 'author_profile': 'https://Stackoverflow.com/users/2567', 'pm_score': 0, 'selected': False, 'text': '<p>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).</p>\n'}, {'answer_id': 51183, 'author': 'Geri Langlois', 'author_id': 4888, 'author_profile': 'https://Stackoverflow.com/users/4888', 'pm_score': 0, 'selected': False, 'text': '<p>You can buy a fairly inexpensive subscription to zipcodes with lat and long info here: <a href="http://www.zipcodedownload.com/" rel="nofollow noreferrer">http://www.zipcodedownload.com/</a> </p>\n'}, {'answer_id': 93803, 'author': 'James Schek', 'author_id': 17871, 'author_profile': 'https://Stackoverflow.com/users/17871', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n\n<p>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). <a href="http://www.census.gov/geo/www/cob/zt_metadata.html" rel="nofollow noreferrer">http://www.census.gov/geo/www/cob/zt_metadata.html</a>. </p>\n\n<p>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.</p>\n\n<p>Update: The 2010 Census data can be found at:\n<a href="http://www2.census.gov/census_2010/" rel="nofollow noreferrer">http://www2.census.gov/census_2010/</a></p>\n'}, {'answer_id': 416355, 'author': 'coldfusionPaul', 'author_id': 50715, 'author_profile': 'https://Stackoverflow.com/users/50715', 'pm_score': -1, 'selected': False, 'text': '<p>geonames has an extensive set of ws that can handle this (among others): \n<br><br>\n<a href="http://www.geonames.org/export/web-services.html#findNearbyPostalCodes" rel="nofollow noreferrer">http://www.geonames.org/export/web-services.html#findNearbyPostalCodes</a><br>\n<a href="http://www.geonames.org/export/web-services.html#findNearbyPlaceName" rel="nofollow noreferrer">http://www.geonames.org/export/web-services.html#findNearbyPlaceName</a></p>\n'}, {'answer_id': 434866, 'author': 'peSHIr', 'author_id': 50846, 'author_profile': 'https://Stackoverflow.com/users/50846', 'pm_score': -1, 'selected': False, 'text': '<p>Another reverse geocoding provider that hasn\'t been listed here yet is <a href="http://www.openstreetmap.org/" rel="nofollow noreferrer" title="OpenStreetMap main site">OpenStreetMap</a>: you can use their <a href="https://stackoverflow.com/questions/2283689/can-anyone-recommend-a-free-geocoding-service/2387299#2387299">Nominatim</a> search service.</p>\n\n<p>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.</p>\n'}, {'answer_id': 434991, 'author': 'bob', 'author_id': 23805, 'author_profile': 'https://Stackoverflow.com/users/23805', 'pm_score': 0, 'selected': False, 'text': '<p>Or google\'s reverse geocoding</p>\n\n<p><a href="http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct" rel="nofollow noreferrer">link</a></p>\n\n<p><a href="http://maps.google.com/maps/geo?output=xml&amp;q=" rel="nofollow noreferrer">http://maps.google.com/maps/geo?output=xml&amp;q=</a>{0},{1}&amp;key={2}&amp;sensor=true&amp;oe=utf8</p>\n\n<p>where 0 is latitude 1 is longitude</p>\n'}, {'answer_id': 10503765, 'author': 'James D', 'author_id': 688365, 'author_profile': 'https://Stackoverflow.com/users/688365', 'pm_score': 1, 'selected': False, 'text': '<p>You have two main options:</p>\n\n<h2>Use a Reverse Geocoding Service</h2>\n\n<ul>\n<li>Google\'s can only be used in conjunction with an embedded Google Map on the same page, so I don\'t recommend it unless that is what you are doing.  </li>\n<li>Yahoo has a good one, see <a href="http://developer.yahoo.com/search/local/V3/localSearch.html" rel="nofollow">http://developer.yahoo.com/search/local/V3/localSearch.html</a></li>\n<li>I\'ve not used OpenStreetMap\'s.  Their maps look very detailed and thorough, and are always getting better, but I\'d be worried about latency and reliability, and whether their address data is complete (address data is not directly visible on a map, and OpenStreetMap is primarily an interactive map).</li>\n</ul>\n\n<h2>Use a Map of the ZIP Codes</h2>\n\n<p>The US Census publishes a map of US ZIP codes <a href="http://www.census.gov/geo/ZCTA/zcta.html" rel="nofollow" title="here">here</a>.  They build this from their smallest statistical unit, a Census Block, which corresponds to a city block in most cases.  For each block, they find what ZIP code is most common on that block (most blocks have only one ZIP code, but blocks near the border between ZIP codes might have more than one).  They then aggregate all the blocks with a given ZIP code into a single area called a Zip Code Tabulation Area.  They publish a map of those areas in ESRI shapefile format.</p>\n\n<p>I know about this because I wrote a Java Library and web service that (among other things) uses this map to return the ZIP code for a given latitude and longitude.  It is a commercial product, so it won\'t be for everyone, but it is fast, easy to use, and solves this specific problem without an API.  You can read about this product here:</p>\n\n<p><a href="http://askgeo.com/database/UsZcta2010" rel="nofollow">http://askgeo.com/database/UsZcta2010</a></p>\n\n<p>And about all of your geographic offerings here:</p>\n\n<p><a href="http://askgeo.com" rel="nofollow">http://askgeo.com</a></p>\n\n<p>Unlike reverse geocoding solutions, which are only available as Web APIs because running your own service would be extremely difficult, you can run this library on your own server and not depend on an external resource.</p>\n'}]
['https://Stackoverflow.com/questions/30962', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1175/']