Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find location using latitude and longitude in python dataframe

import pandas as pd
df = pd.read_excel('your dataframe')
                   
from geopy.geocoders import Nominatim
#We will use this util to create our string tuple to further locate our longitude and latitudes
df['geom'] = df.apply(lambda row: (str(row.LAT),str(row.LONG)),axis=1)
#this prints out our newly created "geom" column
print(df.geom[0]

geolocator = Nominatim(user_agent="geoapiExercises")
df['address'] = df.apply(lambda row: geolocator.reverse(row.geom).address,axis=1)

      #AND VOILA NEWLY ADDED LOCATIONS WILL BE AT THE"address" column
 
PREVIOUS NEXT
Tagged: #find #location #latitude #longitude #python #dataframe
ADD COMMENT
Topic
Name
1+3 =