Advertisement
Sandbird

Draw on map

Jul 18th, 2022
1,718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import csv
  2. from staticmap import StaticMap, CircleMarker
  3.  
  4. m = StaticMap(1000, 900, url_template='http://a.tile.stamen.com/toner/{z}/{x}/{y}.png')
  5.  
  6. def cluster_to_color(cluster):
  7.     alpha = 180
  8.     return {
  9.         '0': (246, 81, 29,alpha),
  10.         '1': (255, 180, 0,alpha),
  11.         '2': (0, 166, 237,alpha),
  12.         '3': (127, 184, 0,alpha),
  13.         '4': (67, 188, 20, alpha),
  14.         '5': (102, 46, 155, alpha),
  15.         '6': (175, 127, 242, alpha),
  16.         '7': (146, 181, 29, alpha),
  17.         '8': (155, 100, 0, alpha),
  18.         '9': (100, 106, 237, alpha),
  19.         '10': (27, 84, 0, alpha),
  20.         '11': (167, 228, 20, alpha),
  21.         '12': (202, 146, 155, alpha),
  22.         '13': (75, 187, 42, alpha),
  23.         '14': (100, 36, 36, alpha),
  24.         '15': (243, 165, 5, alpha),
  25.         '16': (96, 111, 40, alpha),
  26.         '17': (56, 44, 30, alpha)
  27.     }[cluster]
  28.  
  29. with open('results-clusters.csv') as csvfile:
  30.     reader = csv.reader(csvfile, delimiter=';')
  31.     for row in reader:
  32.         marker = CircleMarker((float(row[2]), float(row[1])), cluster_to_color(row[0]), 6)
  33.         m.add_marker(marker)
  34.  
  35. image = m.render(center=[23.7403745, 37.9444012])
  36. image.save('clusters.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement