Shapefile 폴리곤 그리기
이제 폴리곤 지도를 표시해 보겠습니다.
matplotlib.pyplot은 plt로, geopandas는 gpd로 가져왔고, 서비스 구역을 담은 GeoDataFrame service_district가 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 시각화하기
연습 안내
- 먼저 GeoDataFrame에서
.plot()을 호출해 추가 인수 없이 서비스 구역을 그립니다. plt.show()로 확인하세요. 이 단계는 이미 완료되어 있습니다.- 이제
.plot()메서드를 다시 사용하되, 이번에는 도형을 이름별로 색칠하도록column='name'을 추가하고, 그 이름을 보기 위해legend=True를 추가하세요. 마지막으로 그래프를 표시하는 것도 잊지 마세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import packages
import geopandas as gpd
import matplotlib.pyplot as plt
# Plot the Service Districts without any additional arguments
service_district.____()
plt.show()
# Plot the Service Districts, color them according to name, and show a legend
service_district.plot(____ = 'name', ____ = True)
plt.____()