동네 중심으로부터의 예술 작품 거리
이제 중심점과 예술 작품 위치를 미터 단위로 변환했으니, 실제로 거리를 계산해 볼 차례예요.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 시각화하기
연습 안내
- 보기 좋은 출력에 도움이 되는 패키지를 임포트하세요.
art_dist_meters를 반복(iterate)하여 사전art_distances를 만드세요. 키는title, 값은center로부터의distance()가 되도록 하세요.GeoSeries.distance()에other인수로center를 전달하세요.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)