DataFrame에서 GeoDataFrame 구성하기
이 연습 문제에서는 Nashville Public Art DataFrame에서 geopandas GeoDataFrame을 만듭니다. CRS를 지정하고 지오메트리를 정의해야 해요. 이렇게 준비하면 예술 데이터와 동네(neighborhood) 데이터를 공간 조인해서 어느 동네에 공공 미술이 가장 많은지 알아볼 수 있어요.
Nashville Public Art 데이터는 art로 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 시각화하기
연습 안내
art데이터의head()를 출력하세요.geopandas의points_from_xy()메서드를 사용해artDataFrame에 지오메트리 열을 만드세요.art를 사용해 GeoDataFrame을 만들고 이름을art_geo로 하세요.crs는neighborhoods.crs와 같게 설정하고,geometry는 방금 생성한 열로 설정하세요.art_geo의type()을 출력해 GeoDataFrame인지 확인하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
# Print the first few rows of the art DataFrame
print(art.____())
# Create a geometry column in art
art['geometry'] = gpd.____(art.lng, art.lat)
# Create a GeoDataFrame from art and verify the type
art_geo = gpd.GeoDataFrame(art,
____ = neighborhoods.crs,
____ = art.geometry)
print(type(____))