NANP Area Code Locator
Reverse-geocode latitude/longitude to NANP telephone area codes. Works offline; ships a compact Parquet of polygons.
✨ Features
- 🔎 Reverse-geocode
(lat, lon)→ area code(s) - ⚡ Fast local lookups (vectorized GeoPandas + spatial index)
- 🪪 NANP coverage (US, Canada, participating Caribbean)
- 🧳 Zero setup — packaged Parquet data included (~29 MB)
- 🧭 CRS handled automatically (WGS84 in / projected out as needed)
- 🧵 Simple API & CLI (
lookup()andarea-code-lookup)
📦 Install
pip install area-code-locator
# From source:
git clone https://github.com/Eat-A-Fish/area-code-locator.git
cd area-code-locator
pip install -e .
🚀 Quickstart
from area_code_locator import lookup, batch_lookup
# Single point (returns all matching/overlay codes by default)
codes = lookup(40.7128, -74.0060) # NYC
print(codes) # -> ['212', '646', '917', ...]
# First/primary only
code = lookup(34.0522, -118.2437, return_all=False) # LA
print(code) # -> '213'
# Batch
points = [(40.7128, -74.0060), (41.8781, -87.6298)]
print(batch_lookup(points)) # -> [['212', ...], ['312', ...]]
🖥️ CLI
area-code-lookup --lat 40.7128 --lon -74.0060
# -> 917
area-code-lookup --lat 40.7128 --lon -74.0060 --all
# -> ["212", "646", "917", ...]
🧪 API
lookup(lat: float, lon: float, return_all: bool = True) -> Union[str, List[str]]
batch_lookup(points: List[Tuple[float, float]], return_all: bool = True) -> List[Union[str, List[str]]]
return_all=True→ all matching/overlay area codesreturn_all=False→ first/primary area code
Advanced
from area_code_locator import AreaCodeLocator
loc = AreaCodeLocator() # uses bundled data
loc_custom = AreaCodeLocator("path/to/area-codes.parquet")
loc.lookup(40.7128, -74.0060, return_all=True)
🗺️ Data
The package includes a preprocessed Parquet file of area-code polygons, so no setup is required.
Using your own data:
- Parquet with a polygon geometry column
- An area-code column named one of:
area_code,areacode,npa, orcode - CRS: EPSG:4326 (WGS84)
🛠️ Development
pip install -e ".[dev]"
pytest
🙏 Acknowledgments
Area-code boundaries derived from public NANP datasets (e.g., projects compiling NANP polygons). Thanks to the open geospatial community for GeoPandas/Shapely/PyProj.
📄 License
MIT © Area Code Locator Contributors
Metadata
Release files for area-code-locator 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| area_code_locator-0.2.1.tar.gz | 23.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| area_code_locator-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.2 MB
Release files / area_code_locator-0.2.1.tar.gz
| Download URL | area_code_locator-0.2.1.tar.gz |
|---|---|
| Size | 23.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e01c3a9ad02074e3db63ec6fd42b32d3b515391dcc84c6d5298ecba4857e8f21
|
|
BLAKE2b-256 checksum How to use checksums |
2447e5f0a3961996b2c919300bad03972f5c9b9848dddceb81fc8c32baa37c7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / area_code_locator-0.2.1-py3-none-any.whl
| Download URL | area_code_locator-0.2.1-py3-none-any.whl |
|---|---|
| Size | 23.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2c54c2dc29e98653104f64aa92d4c7f1ece33a6ab85cd67c84207587c151ecb
|
|
BLAKE2b-256 checksum How to use checksums |
a95dc21661a63d2c66c84cb837e69342b97f4df3eb31b9fe4283d8b6049bc2e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|