Tạo bản đồ Twitter

Phân tích dữ liệu mạng xã hội bằng Python

Alex Hanna

Computational Social Scientist

Giới thiệu Basemap

Ví dụ đường đồng mức trong Basemap

  • Thư viện vẽ bản đồ hai chiều
  • Xây dựng trên matplotlib
  • Chuyển đổi tọa độ sang các phép chiếu bản đồ
Phân tích dữ liệu mạng xã hội bằng Python

Bắt đầu với Basemap

from mpl_toolkits.basemap 
    import Basemap

m = Basemap(projection='merc', llcrnrlat = -35.62, llcrnrlon = -17.29, urcrnrlat = 37.73, urcrnrlon = 51.39)
m.fillcontinents(color='white') m.drawcoastlines(color='gray') m.drawcountries(color='gray')

Kết xuất Basemap của châu Phi

Phân tích dữ liệu mạng xã hội bằng Python

Vẽ các điểm

africa = pd.read_csv('africa.csv')
longs  = africa['CapitalLongtiude']
lats   = africa['CapitalLatitude']

m = Basemap(...)
m.fillcontinents(color='white', zorder = 0) m.drawcoastlines(color='gray') m.drawcountries(color='gray')
m.scatter(longs.values, lats.values, latlon = True, alpha = 0.7)

Thủ đô châu Phi trong Basemap

Phân tích dữ liệu mạng xã hội bằng Python

Dùng màu sắc

africa = pd.read_csv('africa.csv')
longs  = africa['CapitalLongtiude']
lats   = africa['CapitalLatitude']
arabic = africa['Arabic']

m = Basemap(...)
m.fillcontinents(color='white', 
    zorder = 0)
m.drawcoastlines(color='gray')
m.drawcountries(color='gray')

m.scatter(longs.values, lats.values, latlon = True, c = arabic.values, cmap = 'Paired', alpha = 1)

Thủ đô châu Phi, nói tiếng Ả Rập

Phân tích dữ liệu mạng xã hội bằng Python

Cùng luyện tập nào!

Phân tích dữ liệu mạng xã hội bằng Python

Preparing Video For Download...