按经纬度查找电话区号
寻找一种方法来获取给定纬度和经度的电话区号列表(如果需要,还可以提供给定的国际代码)。请注意,我不是在谈论国际拨号前缀,而是在谈论其中的区号。
例如,科罗拉多州丹佛市的区号为 303 和 720。其位置为 39.739 -104.985,位于 NANP 1 中。因此,给定 39.739,-104.985,1,我想取回 [303,720]。
库、Web 服务、数据库或需要解析为数据库的原始数据(例如,形状点的网页)都很好,并且覆盖范围越广越好,但仅 NANP 1 就会有很大帮助。
请注意,我已经使用 MaxMind 并且可以将 lat-lng 转换为假 IP 并将其用作查找键,但 MaxMind 声称仅美国区号(无论它们真正意味着美国还是实际上 NANP 我尚未测试)并且似乎只有 1每个位置(例如丹佛仅为 303)。所以这是一种可能性,只是不是很好。
更新:我发现了一些更相关的信息,但没有明确的解决方案,因此我在这里列出它而不是在答案中:
我能够找到两个美国数据库http://www.area-codes.com/area-code-database.asp 和 http://www.nationalnanpa.com/area_codes/index.html(页面下方 50%,MS Access 文件。 )前者包括纬度/经度,价格为 450 美元,后者需要最近邻匹配,正如 KeithS 所说(这可能是他发现的 NANPA 城市查询的同一个数据库。)
此外,我发现的信息暗示 Teleatlas 有区号边界地图和ESRI 包含带有 ArcGIS 副本的区号形状文件。 Maponics 似乎有可用的数据:Maponics 数据的 Google 地图实现位于 http://www.usnaviguide.com/areacode.htm 。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哇。您肯定需要某种预先存在的点数据库。我的第一个想法是 ZIPList5 地理编码。它包括每个有效的美国邮政编码的经纬度数据,因此您可以将这些数据放入数据库表中,对其进行索引,并通过您有权访问的任何地理信息进行搜索。您可以花 40 美元购买一份,企业级使用只需 100 美元。唯一的问题是,该数据库仅包含每个邮政编码的“主要”区号,因此拥有多个邮政编码的都市区(达拉斯、芝加哥、纽约市)不会显示所有邮政编码。
您可以使用我找到的一些免费数据尝试双管齐下的方法:对于给定的纬度和经度,对 USGS 地名信息系统;它包括有关每个人类居住中心和每个命名地标特征的信息,以及其中心的纬度/经度坐标。现在,您已将纬度/经度点映射到最近的城镇/城市、邮政编码、县和州。现在,您可以将其与美国区号列表进行比较,以查找区域与 USGS 的任何或所有识别信息相匹配的代码。这一切都是免费的,并且最终会为您提供所需的内容,但是您可能需要做一些工作来将两组数据“按摩”成可以有效交叉引用的内容,和/或您需要实现一个好的“搜索引擎”,可以准确地找到最近邻的命名点,然后找到与名称匹配的位置的区号。
另一件值得关注的事情是 NANPA,它首先管理区号分配。我确信他们有更全面的可下载数据库,但我能找到的唯一免费公共访问是这个搜索页面,它将找到任何人口超过 2 万的城市的区号。您可以将纬度/经度数据转换为城市和州,然后点击此搜索页面:NANPA城市查询
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
这是一个选项:
http://geocoder.ca/39.739,-104.985?geoit=xml
Here is an option:
http://geocoder.ca/39.739,-104.985?geoit=xml