ArcGIS is a software that enables to analyze and visualize geospatial data. It also provides location services such as Google Maps and OpenStreetMap.
from geopy.geocoders import ArcGIS geolocator_arcgis = ArcGIS() location = geolocator_arcgis.geocode(address1) print('Latitude: '+str(location.latitude)+', Longitude: '+str(location.longitude))
OpenAI
This time there is no issue in obtaining the pair of coordinates. We can proceed on extending this operation to all the addresses:
df['LAT_LON_arcgis'] = df['unique_address'].apply(lambda x: service_geocode(geolocator_arcgis,x)) df[['unique_address','LAT_LON','LAT_LON_osm','LAT_LON_arcgis']].head()
OpenAI
Taking a look at the first rows of the dataset, we can see the pair of coordinates obtained with ArcGIS are similar to the ones obtained before, there is only a slight difference.
Measure distance between two places
Another functionality of Geopy is that it allows us to calculate the distance between two points. This is possible using the geodesic distance obtained between two pairs (latitude, longitude).
from geopy.distance import geodesic point1 = df.LAT_LON_arcgis.iloc[0] point2 = df.LAT_LON_arcgis.iloc[1] distance = geodesic(point1, point2) print('The distance between {} and {} is {} meters'.format(df.Name.iloc[0],df.Name.iloc[1],distance.meters))
OpenAI
The distance between these two museums is approximately 2 kilometers.
Leave a Reply