Twitter JSON内の地理データ

Python でのソーシャルメディアデータ分析

Alex Hanna

Computational Social Scientist

ツイート本文内の位置情報

位置情報を含むツイートのテキスト

Python でのソーシャルメディアデータ分析

ユーザー定義の位置情報

ユーザー定義の位置情報

print(tweet['user']['location'])
Bay Area
Python でのソーシャルメディアデータ分析

place JSON

境界ボックスの図

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',
 ...}
Python でのソーシャルメディアデータ分析

重心を計算する

境界ボックスの図

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
Python でのソーシャルメディアデータ分析

coordinates JSON

単一座標の場所

print(tweet['coordinates'])
{'type': 'Point', 
'coordinates': [-72.2833, 
                 21.7833]}
Python でのソーシャルメディアデータ分析

練習しましょう!

Python でのソーシャルメディアデータ分析

Preparing Video For Download...