จุดศูนย์กลางของย่าน Urban Residents
ต่อไปจะหาจุดศูนย์กลางของ urban_poly_3857 แล้วพล็อตลงบนรูปหลายเหลี่ยม
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python
คำแนะนำการฝึกหัด
- สร้าง
downtown_centerจากurban_poly_3857โดยใช้แอตทริบิวต์centroidของ GeoSeries - พิมพ์ประเภทข้อมูลของ
downtown_center - พล็อต
urban_poly_3857เป็น ax โดยกำหนดcolorเป็นlightgreen - พล็อต
downtown_centerโดยตั้งค่าax = axและcolor = blackระบบจะหมุนป้ายแกน x ให้อัตโนมัติ และมีโค้ดสำหรับแสดงกราฟเตรียมไว้ให้แล้ว
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create downtown_center from urban_poly_3857
downtown_center = urban_poly_3857.____.____
# Print the type of downtown_center
print(type(downtown_center))
# Plot the urban_poly_3857 as ax and add the center point
ax = ____.plot(color = 'lightgreen')
____.plot(ax = ____, color = 'black')
plt.xticks(rotation = 45)
# Show the plot
plt.show()