I have a bunch of telephone numbers (just the area codes), and I'd like to geolocate them and make a map, but I haven't had too much luck googling for shapefiles for Area Codes. Surely these are in the public domain?
[GIS] Shapefiles for U.S. Area Codes (NANP)
areadatashapefile
Related Solutions
Read the 'importing data' section of the manual, found on page 54. Here's the manual: http://www.cetaecoresearch.com/Software/Pythagoras/Pythagoras_manual.pdf
It states that you can import excel data. I recommend exporting your GIS data to csv, open in excel, save as excel doc, import to pythagoras.
If you have programming skills you may be able write a script to convert GIS data to the pythagoras metafile format.
You can create a function to find the utm zone for the centroid of the lat, long point then project to that zone and calculate area. I think it should work worldwide
import geopandas as gpd
import utm #pip install utm
from pyproj import CRS
df = gpd.read_file(r'/home/bera/Desktop/GIStest/4_buildings_4326.shp')
# df.geometry.area
#0 1.499222e-06
#1 1.783689e-06
#2 7.173407e-07
#3 1.983493e-06
def findtheutm(aGeometry):
"""A function to find a coordinates UTM zone"""
x, y, parallell, latband = utm.from_latlon(aGeometry.centroid.y, aGeometry.centroid.x)
if latband in 'CDEFGHJKLM': #https://www.lantmateriet.se/contentassets/379fe00e09d74fa68550f4154350b047/utm-zoner.gif
ns = 'S'
else:
ns = 'N'
crs = "+proj=utm +zone={0} +{1}".format(parallell, ns) #https://gis.stackexchange.com/questions/365584/convert-utm-zone-into-epsg-code
crs = CRS.from_string(crs)
_, code = crs.to_authority()
return int(code)
epsg = findtheutm(df.geometry.iloc[0]) #Input the dfs first geometry to the function and get utm epsg code back
df['correctArea'] = df.to_crs(epsg).area # /1e6 for km2
# df
# id ... correctArea
# 0 585331 ... 9140.157424
# 1 585332 ... 10874.176357
# 2 585337 ... 4373.700636
# 3 2488763 ... 12093.625510
Best Answer
You could also try using the MaxMind GeoLite City dataset. This dataset is a point layer that contains both the AreaCode and MetroCode (Example: AreaCode - MetroCode - XXXX). If you have a metrocode, you might be able to get closer than just with area code by finding the nearest City point that shares both the area code and metrocode of the phone number you are testing.
If you are trying to get the center of the area code, you could try creating something like a Voronoi diagram and dissolve the polygons to generate area-code like boundaries. I will tell you, however, tried this method already, there are a lot of outliers that will need to be cleaned up in order to get a decent output of area codes (see image below). It certainly wouldn't be perfect, but would give you an approximation.
There are some other questions that have mentioned the MaxMind dataset that you may want to read for additional information.
Initial map, all points:
Update: After doing some pre-processing of the points to remove outliers and clipping to the US boundaries, the result turned out pretty good, I thought.