A Python library to convert between (address) latitude/longitude and DIGIPINs.
Project description
DigiPinConverter
A Python library to convert geographic coordinates (latitude/longitude) to DIGIPIN — a unique 10-character grid-based location identifier — and vice versa. It also supports address-to-DIGIPIN conversion using the Google Maps Geocoding API.
🚀 Features
- Convert latitude/longitude → DIGIPIN
- Convert DIGIPIN → latitude/longitude
- Convert Address → DIGIPIN (via Google Maps API)
- Based on Government of India’s standard 4x4 DIGIPIN grid system
- Lightweight and easy to integrate
📦 Installation
pip install digiPYn
Use the
-eflag if you’re developing or testing locally.
pip install -e .
🧠 Usage
from digiPYn import DigiPinConverter
# Initialize the converter
converter = DigiPinConverter()
# Convert coordinates to DigiPIN
digipin = converter.get_digipin_from_lat_long(15.00236, 78.08250)
print("DigiPIN:", digipin)
# Convert DigiPIN to coordinates
lat, lon = converter.get_lat_long_from_digipin(digipin)
print("Coordinates:", lat, lon)
# Convert address to DigiPIN (Google Maps API key required)
digipin_from_address = converter.get_digipin_from_address("Kurnool, India")
print("Address DigiPIN:", digipin_from_address)
🔐 API Key Configuration
To use the address-to-DIGIPIN conversion feature, a Google Maps Geocoding API key is required.
🔄 How It Works
- The first time the Google Maps API is called, the user will be prompted to input their API key.
- The key is then securely saved in a
config.jsonfile at a platform-specific location:- Windows:
%APPDATA%/digipin_converter/config.json - Linux/macOS:
~/.config/digipin_converter/config.json
- Windows:
This behavior is handled automatically by the library's config.py module.
🧼 Delete the API Key
To remove the saved API key at any time, simply call:
from digipYn.config import delete_api_key
delete_api_key()
This will delete the config.json file storing your credentials.
💡 Pro Tip (Optional Manual Setup)
If you prefer, you can also manually set the environment variable GOOGLE_API_KEY before running your script:
export GOOGLE_API_KEY="your_key_here" # Linux/macOS
set GOOGLE_API_KEY=your_key_here # Windows CMD
$env:GOOGLE_API_KEY="your_key_here" # Windows PowerShell
The library will prioritize this over the saved config file.
📁 Project Structure
digipin_converter/
├── digipin_converter/
│ ├── __init__.py
│ ├── converter.py # DigiPinConverter class
│ └── config.py # Handles API key config
├── tests/
│ └── test_converter.py # Unit tests
├── setup.py
├── pyproject.toml
└── README.md
✅ Dependencies
requests
Install with:
pip install -r requirements.txt
🧪 Running Tests
Basic example using pytest:
pytest tests/
📃 License
This project is open-source and available under the MIT License.
📚 References
- This library is based on the DIGIPIN grid logic developed by CEPT-VZG. You can find the original implementation here.
🙏 Credits
- DIGIPIN grid logic adapted from the original work by CEPT-VZG.
✍️ Author
Created by Kawsshikh Sajjana Gandla
Feel free to contribute or report issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file digipyn-0.1.0.tar.gz.
File metadata
- Download URL: digipyn-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6658f8b2c0342fa7fa2f2bfe10fc9bdca6f4a4f08f38f431d871cfe2ab2cbaa7
|
|
| MD5 |
2bf0001dad29d6cb0c197734498eed12
|
|
| BLAKE2b-256 |
5034ad0cec79340801f40d7295ad868838c67af6854719588912d8742f64f7fe
|
File details
Details for the file digipyn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: digipyn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18942a7651816f658b970d311e51242bc8ee4ef914f05cd5870c25d041544541
|
|
| MD5 |
baa5e8c945a49d74ecbc4edcda23577e
|
|
| BLAKE2b-256 |
da708993f39da3ee33e0c6100b654e9a0ab1353133ab27416433ba85da391379
|