Twitter JSON의 지리 데이터

Python으로 소셜 미디어 데이터 분석하기

Alex Hanna

Computational Social Scientist

Twitter 텍스트의 위치 정보

위치 텍스트가 포함된 트윗

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...