-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate_Map.py
More file actions
61 lines (48 loc) · 1.15 KB
/
Copy pathgenerate_Map.py
File metadata and controls
61 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''
Author: Prakhar Mishra
Date: 13/01/2016
'''
# Importing Packages
import pygmaps
import webbrowser
import csv
import geocoder
import random
import re
import sys
# Opening and getting marker for the input file
data = open(str(sys.argv[1]), 'r')
data_reader = csv.reader(data)
# Reads only the geo information and appends it into
# places list
places = []
for line in data_reader:
places.append(line[3])
# Cleans the text
regex = "(\")"
s = [re.sub(regex,'',i) for i in places]
# From 1 because to skip the header
# s[0] - Header of csv
# Gets the latitite and longitute from names
count = 0
data_latlng = []
for i in s[1:]:
if i != 'Location data not found !!':
g = geocoder.google(str(i))
dta = g.latlng
if len(dta) != 0:
data_latlng.append(g.latlng)
else:
pass
else:
pass
points = data_latlng
# # # Defining Center of map ( Portugal )
mymap = pygmaps.maps(37.933426, -7.496694, 3)
# For points in points, plots the data in maps
for i in points:
mymap.addpoint(float(i[0]),float(i[1]),'#FF00FF')
mymap.draw('mymap.html')
print 'Drawn'
# Opens the browser when plotting is complete
webbrowser.open_new_tab('mymap.html')