ข้อมูลภูมิศาสตร์ใน Twitter JSON

การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

Alex Hanna

Computational Social Scientist

ตำแหน่งในข้อความทวีต

ทวีตที่มีข้อความระบุตำแหน่ง

การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

ตำแหน่งที่ผู้ใช้กำหนดเอง

ตำแหน่งที่ผู้ใช้กำหนดเอง

print(tweet['user']['location'])
Bay Area
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

place JSON

ภาพประกอบ bounding box

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

การคำนวณจุดศูนย์กลาง

ภาพประกอบ bounding box

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