task_webim




Pay Notebook Creator: Евгений Серёгин0
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]:
# Click the Green Button to transform this Jupyter Notebook into a CrossCompute Tool
target_folder = '/tmp/map-locations'
location_table_path = 'waterfalls.csv'
In [7]:
from os.path import join
from pandas import read_csv
location_table = read_csv(location_table_path)
location_table
Out[7]:
Name Height (meters)
0 Bridalveil Fall, California 617
1 Multnomah Falls, Oregon 189
2 Niagara Falls, New York 51
In [8]:
import geopy
geocode = geopy.GoogleV3().geocode
geocode('New York, NY')
Out[8]:
Location((40.7127837, -74.0059413, 0.0))
In [9]:
latitudes = []
longitudes = []
for name in location_table['Name']:
    print(name)
    location = geocode(name)
    latitudes.append(location.latitude)
    longitudes.append(location.longitude)
Bridalveil Fall, California
Multnomah Falls, Oregon
Niagara Falls, New York
In [10]:
location_table['Latitude'] = latitudes
location_table['Longitude'] = longitudes
In [11]:
location_table
Out[11]:
Name Height (meters) Latitude Longitude
0 Bridalveil Fall, California 617 37.716669 -119.646389
1 Multnomah Falls, Oregon 189 45.576160 -122.115776
2 Niagara Falls, New York 51 43.096214 -79.037739
In [12]:
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)
In [13]:
print('location_geotable_path = %s' % target_path)
location_geotable_path = /tmp/map-locations/locations.csv

Landmarks

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