I need to convert longitude and latitude coordinates to either country or city, is there an example of this in python?
thanks in advance!
# Python3 program for reverse geocoding.
# importing necessary libraries
import reverse_geocoder as rg
from pandas import DataFrame
import pandas as pd
def reverseGeocode(coordinates):
result = rg.search(coordinates)
return result
# Coorinates tuple.Can contain more than one pair.
if __name__ == "__main__":
result = []
path = "CSV_NAME.CSV"
df = pd.read_csv(path, error_bad_lines=False)
for i in range(0, len(df)):
coordinates =(df["latitude"], df["longitude"])
result.append(reverseGeocode(coordinates))
print(result)