GeoDataFrame 만들기와 geometry 살펴보기
내슈빌의 서비스 구역이 어디에 있는지 확인해 봅시다. 서비스 구역 shapefile의 경로는 변수 shapefile_path에 저장되어 있어요.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 시각화하기
연습 안내
geopandas를 일반적으로 쓰는 별칭gpd로 임포트하세요.geopandas를 사용해 서비스 구역 shapefile을 읽고,head()메서드로 처음 5개 행을 확인하세요.- 첫 번째 행(행 이름은 '0')의 geometry 필드를 출력해 해당 필드에 어떤 데이터가 들어 있는지 보세요. 이를 위해
service_district.loc[0, 'geometry']를print()함수에 전달하면 됩니다.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import geopandas
import ____ as ____
# Read in the services district shapefile and look at the first few rows.
service_district = gpd.____(shapefile_path)
print(service_district.____())
# Print the contents of the service districts geometry in the first row
print(service_district.loc[0, '____'])