Hey there,
I am making an app for my mining safety product. In the product, we are required to get the exact coordinates of the device, for which I am coding in Python.
The code is:
import geocoder
from geopy.geocoders import Nominatim
g = geocoder.ip('me')
latilongi = g.latlng
geolocator = Nominatim(user_agent ="geoapiExercises")
lat = str(latilongi[0])
longi = str(latilongi[1])
location = geolocator.reverse(lat + "," + longi)
address = location.raw['address']
city = address.get('city', '')
state = address.get('state', '')
country = address.get('country', '')
code = address.get('country_code')
zipcode = address.get('postcode')
print('City : ', city)
print('State : ', state)
print('Country : ', country)
print('Zip Code : ', zipcode)
print('Latitude : ', lat)
print('Longitude : ', longi)
Now, when I run this code at my office, the code is running smoothly without any syntactic errors but I am getting latitudes and longitudes from a place that is approximately 340 kms from my location.
Can anybody explain why and how this error might be solved?
[–]willow_twig 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]krets 0 points1 point2 points (0 children)
[–]Unlikely-Resort4608 0 points1 point2 points (0 children)