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

การพล็อตย่าน Urban Residents และงานศิลปะ

ตอนนี้คุณทราบแล้วว่างานศิลปะส่วนใหญ่อยู่ในย่าน Urban Residents ในแบบฝึกหัดนี้ จะสร้างพล็อตแสดงงานศิลปะในย่านนั้น โดยเริ่มจากการกรองเฉพาะ urban_art จาก neighborhood_art และกรอง urban_polygon จาก neighborhoods จากนั้นสร้างพล็อต polygon เป็น ax ก่อน แล้วจึงเพิ่มพล็อตของงานศิลปะลงไป

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • สร้าง GeoDataFrame ชื่อ urban_art โดยใช้ตัวเข้าถึง .loc[] เพื่อดึงเฉพาะงานศิลปะในย่าน "Urban Residents"
  • ใช้ .loc[] อีกครั้งเพื่อสร้าง GeoDataFrame ชื่อ urban_polygon จาก neighborhoods โดยดึงเฉพาะ polygon ของ "Urban Residents"
  • พล็อต urban_polygon เป็น ax และกำหนด color เป็น lightgreen
  • พล็อตงานศิลปะใน urban_art โดยส่งอาร์กิวเมนต์ 3 ตัว ได้แก่ กำหนด ax = ax เพื่อเพิ่มพล็อตนี้ลงบน urban_polygon ใช้ type เพื่อกำกับชื่อจุด และกำหนด legend = True

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Create urban_art from neighborhood_art where the neighborhood name is Urban Residents
urban_art = neighborhood_art.loc[neighborhood_art.name == ____]

# Get just the Urban Residents neighborhood polygon and save it as urban_polygon
urban_polygon = neighborhoods.loc[____.____ == "Urban Residents"]

# Plot the urban_polygon as ax 
ax = ____.____(color = 'lightgreen')

# Add a plot of the urban_art and show it
urban_art.plot( ax = ax, ____ = 'type', legend = True);
plt.show()
แก้ไขและรันโค้ด