距離社區中心的藝術品距離
現在你已經有中心點與藝術品位置,且單位已換成可用來計算公尺距離,是時候執行距離計算了。
本練習屬於課程
在 Python 視覺化地理空間資料
練習說明
- 匯入可協助漂亮列印的套件。
- 走訪
art_dist_meters建立字典art_distances,以title為鍵,並以從center的distance()為值。將center作為GeoSeries.distance()的other參數傳入。 - 使用
pprint的pprint方法來漂亮列印art_distances。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import package for pretty printing
import ____
# Build a dictionary of titles and distances for Urban Residents art
art_distances = {}
for row in ____.iterrows():
vals = row[1]
key = vals['title']
ctr = vals[____]
art_distances[key] = vals['geometry'].distance(____)
# Pretty print the art_distances
____.____(art_distances)