Trace location using your Phone number using python
What is location tracing?
Location tracing refers to the technology of determining your location in terms of latitude and longitude using satellite signals. It uses the technology of the Global positioning system also known as GPS. It requires a total set of 24 global satellites revolving around Earth. In modern times mostly every mobile phone has a GPS chip which makes it easy to track the location.
Why it is Useful?
It is indeed a useful technology and can have multiple advantages, some of them are :
- Tracing can help in finding a lost person.
- Tracing can help to provide medical emergencies.
- Tracing can help to find criminals.
- Tracing can track armed personnel in a mission.
etc.
How can we do it?
It is not a simple task but you are a coder so it is simple for you Guys,
we can achieve this using python, Yes python has great potential and can work above your expectation, Do check my blog there are some amazing python projects. So for this project, we will require some modules which are phonenumbers and geocoder. Import these modules in the project.
import phonenumbers
import geocoder
What is Geocoder?
It is a module that has some predefined sets of instructions or pre-programmed files that we use in our project, It already has many codes that we will use. This module is not preinstalled in the system, so need to download this using the pip operator in the PowerShell.
Logic?
After installing the module :
import phonenumbers
import geocoder
key = 'Use your own key from API'
# from mynumber import number
from phonenumbers import geocoder
number = input("enter your number here")
samNumber = phonenumbers.parse(number)
yourLocation = geocoder.description_for_number(samNumber,"en")
print(yourLocation)
from phonenumbers import carrier
sn = phonenumbers.parse(number , " RO")
print(carrier.name_for_number(sn,"en"))
# latitudes and longitudes
from opencage.geocoder import OpenCageGeocode
geocoder = OpenCageGeocode(key)
query = str(yourLocation)
results = geocoder.geocode(query)
# print(results)
lat = results[0]['geometry']['lat']
lng = results[0]['geometry']['lng']
print(lat,lng)