เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

จุดศูนย์กลางของย่าน 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()
แก้ไขและรันโค้ด