오버레이 결과 살펴보기
토지 이용과 구역(district) 데이터셋을 오버레이했으니, 이제 각 구역의 토지 이용을 더 쉽게 살펴볼 수 있어요. 예시로 사용했던 Muette 구역으로 돌아가 그 구역의 토지 이용을 확인해 봅시다.
GeoPandas와 Matplotlib은 이미 임포트되어 있습니다. 이전 연습 문제에서 overlay() 함수로 만든 결과는 combined로 제공됩니다.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 다루기
연습 안내
combinedGeoDataFrame에 각 폴리곤의 면적을 담은 새 열'area'를 추가하세요.'district_name'이 "Muette"와 같은 행만 추려land_use_muette라는 하위 집합을 만드세요.- 폴리곤 색상을
'class'열로 지정해land_use_muette를 시각화하세요. groupby()메서드를 사용해land_use_muette의 각'class'별 총면적을 계산하고, 결과를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Print the first rows of the overlay result
print(combined.head())
# Add the area as a column
____ = ____
# Take a subset for the Muette district
land_use_muette = combined[____]
# Visualize the land use of the Muette district
land_use_muette.____(____)
plt.show()
# Calculate the total area for each land use class
print(land_use_muette.____(____)['area'].____() / 1000**2)