Python folio marker maps do not show on map despite data

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

#Let Folium determine the scale
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')

- : enter image description here , : enter image description here

+4
2

, , html , javascript-, :///path.

python .

cd , html. $ cd/path/to/generated/html/file

$python -m SimpleHTTPServer 8000

http://localhost:8000/us_states.html ( )

, .

+2

, twitter CSV , , Google Earth. , , .

import sys
import csv
import json

in_file = raw_input("File to read ex: 'C:\\Python27\\twitdata.txt': ")
out_file = raw_input("CSV file/location to write: ")
csvfile = file(out_file, "w")
csvwriter = csv.writer(csvfile)
row = [ "user", "latitude", "longitude" ]
csvwriter.writerow(row)
tweets_file = open(in_file, 'r')
for line in tweets_file:
try:
    tweet = json.loads(line)
    user = tweet['user']['screen_name']
    latitude = tweet["geo"]["coordinates"][0]
    longitude = tweet["geo"]["coordinates"][1]
    row = [ user, latitude, longitude ]
    csvwriter.writerow(row)
except:
    continue

print "done "
csvfile.close()    
0

All Articles