ECSP




Pay Notebook Creator: Haige Cui0
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 [1]:
# CrossCompute
target_folder = '/tmp/map-locations'
location_table_path = 'usa-height-for-3-waterfalls.csv'
In [2]:
from os.path import join
from pandas import read_csv
location_table = read_csv(location_table_path)
location_table
Out[2]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
Name Height in Meters
0 Bridalveil Fall, California 617
1 Multnomah Falls, Oregon 189
2 Niagara Falls, New York 51
In [ ]:
import geopy
geocode = geopy.GoogleV3('AIzaSyDNqc0tWzXHx_wIp1w75-XTcCk4BSphB5w').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}