Lookup telephone area code by latitude and longitude
Asked Answered
A

2

9

Looking for a way to get a list of telephone area codes for a given latitude and longitude (and if necessary a given intl. code.) Note, I'm not talking about international dialing prefixes but the area codes within them.

For example, Denver Colorado is covered by the area codes 303 and 720. It's at 39.739 -104.985 and is in NANP 1. So given 39.739,-104.985,1 I'd like to get back [303,720].

Libraries, web services, DB's, or raw data that needs to be parsed into a DB, e.g., a web page of shape points, are all fine and the more global coverage the better, but just NANP 1 would be a great help.

Note I already use MaxMind and could turn the lat-lng into a fake IP and use that as the lookup key, but MaxMind claims only U.S. area codes (whether they truly mean U.S. or actually NANP I haven't tested) and seemingly only 1 per location (e.g. just 303 for Denver.) So it's a possibility, just not a great one.


UPDATE: I found some more relevant information, but no definitive solutions so I'm listing it here rather than in an answer:

I was able to find two U.S. databases http://www.area-codes.com/area-code-database.asp and http://www.nationalnanpa.com/area_codes/index.html (50% down the page, MS Access file.) The former includes lat/lng for $450 and the latter would require nearest-neighbor matching as KeithS talks about (it's probably the same DB underlying the NANPA City Query he found.)

Additionally I found information that implies Teleatlas has area code boundary maps and that ESRI includes area code shape files with copies of ArcGIS. Maponics seems to have data available: there's a Google Maps implementation of Maponics' data at http://www.usnaviguide.com/areacode.htm.

Armorer answered 28/10, 2010 at 22:37 Comment(0)
H
6

Wow. You'll definitely need some sort of pre-existing database of points. My first thought was ZIPList5 Geocode. It includes lat-long data for each active U.S. ZIP code, so you can throw this data in a DB table, index the hell out of it, and search by just about any geographic info you'd have access to. You can buy one copy for $40, with enterprise-level use for $100. Only problem is that this DB has only the "primary" area code for each ZIP code, so metro areas that have more than one (Dallas, Chicago, NYC) aren't going to show all of them.

You could try a two-pronged approach with some free data I found: for a given latitude and longitude, do a nearest-neighbors search of the data in the USGS Geographic Names Information System; it includes information on every human habitation center, and every named landmark feature, with lat/long coordinates of their centers. You now have your lat/long point mapped to the nearest town/city, ZIP code, county, and state. Now, you can compare that against this list of U.S. Area Codes, to find area codes matching any or all of the identifying information from the USGS. This is all free, and will eventually get you what you need, but you'll probably have to do some work to "massage" the two sets of data into something you can efficiently cross-reference, and/or you'll need to implement a good "search engine" that will accurately find nearest-neighbor named points, and then find area codes for locations matching the names.

One more thing to look at is NANPA, which administers area code assignment to begin with. I'm sure they have a more comprehensive downloadable DB, but the only free public access I could find was this search page, which will find area codes for any city with >20k people. You could turn your lat/long data into a city and state, and then hit this search page: NANPA City Query

Hembree answered 28/10, 2010 at 23:8 Comment(1)
Just to expand on the second paragraph; using the web-service or free DB from Geonames is another alternative for doing the nearest-neighbor search.Armorer
D
2

Here is an option: http://geocoder.ca/39.739,-104.985?geoit=xml

<TimeZone>America/Denver</TimeZone>
<AreaCode>720,303</AreaCode
Deathlike answered 23/11, 2015 at 22:12 Comment(2)
geocoder.ca no longer appears to have telephone area code data as of 2020.Polyzoic
it is back now: <geodata> <latt>39.738653</latt> <longt>-104.985467</longt> <city>Arvada</city> <prov>CO</prov> <postal>80214</postal> <stnumber>101</stnumber> <staddress>14TH AVE</staddress> <inlatt>39.739</inlatt> <inlongt>-104.985</inlongt> <distance>0.056</distance> <neighborhood>Civic Center</neighborhood> <neighborhoods> <neighborhoodname>Civic Center,Denver Colorado</neighborhoodname> </neighborhoods> <TimeZone>America/Denver</TimeZone> <AreaCode>720,303</AreaCode> <confidence>0.9</confidence>Deathlike

© 2022 - 2024 — McMap. All rights reserved.