Geografische data in Twitter-JSON

Socialmediagegevens analyseren in Python

Alex Hanna

Computational Social Scientist

Locaties in Twitter-tekst

Tweet met locatie in tekst

Socialmediagegevens analyseren in Python

Door gebruiker ingestelde locatie

Door gebruiker ingestelde locatie

print(tweet['user']['location'])
Bay Area
Socialmediagegevens analyseren in Python

place-JSON

Illustratie van begrenzingsvlak

print(tweet['place'])
{'attributes': {},
 'bounding_box': {'coordinates': 
  [[[-80.47611, 37.185195],
    [-80.47611, 37.273387],
    [-80.381618, 37.273387],
    [-80.381618, 37.185195]]],
  'type': 'Polygon'},
 'country': 'United States',
 'country_code': 'US',
 'full_name': 'Blacksburg, VA',
 'name': 'Blacksburg',
 'place_type': 'city',
 ...}
Socialmediagegevens analyseren in Python

Het zwaartepunt berekenen

Illustratie van begrenzingsvlak

coordinates = [
    [-80.47611, 37.185195],
    [-80.47611, 37.273387],
    [-80.381618, 37.273387],
    [-80.381618, 37.185195]]

longs = np.unique( [x[0] for x 
    in coordinates] )
lats  = np.unique( [x[1] for x 
    in coordinates] )

central_long = np.sum(longs) / 2
central_lat  = np.sum(lats) / 2
Socialmediagegevens analyseren in Python

coordinates-JSON

Plaats met enkele coördinaat

print(tweet['coordinates'])
{'type': 'Point', 
'coordinates': [-72.2833, 
                 21.7833]}
Socialmediagegevens analyseren in Python

Laten we oefenen!

Socialmediagegevens analyseren in Python

Preparing Video For Download...