I have a code that follows from a science cookbook for practical cookbooks in which they used folium and twitter to determine the geographic location of the twitter followers. The code works well, and at the end it outputs an html file which should have markers where your subscribers are located. However, there are no markers on my map, despite the availability of data.
Here is the code:
status_geo = []
status_geo_screen_names = []
for fp in friends_profiles:
if ('status' in fp and fp['status']['geo'] is not None and 'screen_name' in fp):
status_geo.append(fp['status']['geo'])
status_geo_screen_names.append(fp['screen_name'])
print status_geo
Output: [{u'type ': u'Point', u'coordinates ': [37.27647779, -121.98564579]}, {u'type': u'Point ', u'coordinates': [33.64158125, -84.43924375]} , {u'pepe ': u'Point', u'coordinates ': [33.81747122, -116.52908589]}, {u'type': u'Point ', u'coordinates': [34.01340657, -118.17538228]}, { u 'type': u'Point ', u'coordinates': [38.7974924, -76.1285375]}, {u'type ': u'Point', u'coordinates ': [43.579385, -116.198543]}, {u' type ': u'Point', u'coordinates': [51.69102332, -0.41811924]}, {u'type ': u'Point', u'coordinates': [40.494286, -74.44376]}, {u'type ' : u 'Point', u'coordinates': [53.60089695, -113.49052185]}
print status_geo_screen_names
:
[u'TicaCoffee ', u'sekouandrews', u'Kimtuitive ', u'isalsa4u', u'ConsWahoo ', u'cre8commongood', u'BrookeHRob ', u'pedrohernandez', u'khueggen ', u'DMCONCREPUMP', u'PhillipLeslie '...]
import folium
from itertools import izip
map = folium.Map(location=[38, -120],zoom_start=3)
for sg, sn in izip(status_geo, status_geo_screen_names):
map.simple_marker(sg['coordinates'], popup=str(sn))
map.create_map(path='us_states.html')
- :
, :
