UPqJb




Pay Notebook Creator: Tembelihle Moyo0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Put Landmarks on a Map

The geopy package is useful for converting location names into spatial coordinates.

In [ ]:
# Click the Green Plane to transform this into a CrossCompute tool
target_folder = '/tmp/map-locations'
location_table_path = 'usa-height-for-3-waterfalls.csv'
In [ ]:
from os.path import join
from pandas import read_csv
location_table = read_csv(location_table_path)
location_table
In [ ]:
import geopy
geocode = geopy.GoogleV3().geocode
geocode('New York, NY')
In [ ]:
latitudes = []
longitudes = []
for name in location_table['Name']:
    location = geocode(name, timeout=5)
    latitudes.append(location.latitude)
    longitudes.append(location.longitude)
    print(name)
In [ ]:
location_table['Latitude'] = latitudes
location_table['Longitude'] = longitudes
location_table
In [ ]:
from invisibleroads_macros.disk import make_folder
from os.path import join
target_path = join(make_folder(target_folder), 'locations.csv')
location_table.to_csv(target_path, index=False)
print('location_geotable_path = %s' % target_path)

Landmarks

{location_geotable : Landmark Map ? Try clicking a circle on the map}